一、代码实现
1.热门关键词挖掘模块
热门关键词挖掘模块的实现需要用到一些常用的数据挖掘技术,如自然语言处理、文本分类、数据聚类等。以下是一个简单的关键词挖掘代码示例:
import jieba
import jieba.analyse
# 加载停用词表
stopwords = [line.strip() for line in open('stopwords.txt', encoding='utf-8').readlines()]
# 加载文本
text = open('input.txt', encoding='utf-8').read()
# 提取关键词
keywords = jieba.analyse.extract_tags(text, topK=20, withWeight=True, allowPOS=('n', 'v'))
# 过滤停用词
keywords = [w for w in keywords if w[0] not in stopwords]
# 输出结果
for keyword, weight in keywords:
print(keyword, weight)
2.视频分析模块
视频分析模块的实现需要用到一些常用的视频处理技术,如视频解析、视频编码、视频特征提取等。以下是一个简单的视频分析代码示例:
import cv2
import numpy as np
# 加载视频
cap = cv2.VideoCapture('video.mp4')
# 获取视频信息
fps = cap.get(cv2.CAP_PROP_FPS)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
# 视频特征提取
frames = []
while True:
ret, frame = cap.read()
if not ret:
break
frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frames.append(frame_gray)
hist = [np.histogram(frame, bins=256, range=(0, 255))[0] for frame in frames]
请求方式
- POST
参数
参数名 | 必选 | 类型 | 说明 |
username | 是 | string | 商户姓名 |
password | 是 | string | 密码 |
id | 是 | int | 代理商ID号 |
mobile | 是 | int | 商户登录手机号码 |
sign | 是 | string | 签名 |
返回示例
错误: { "ec": 400, "em": "商家账号已存在,请更换登录账号" } 正确: { "ec": 200, "em": "添加成功" } |
$video_list = $Video_model->getList($where,$this->index,$this->count,$sort);
$material_model = new App_Model_Douyin_MysqlVideoMaterialStorage($this->sid);
$temp_video_model = new App_Model_Douyin_MysqlVideoTempVideoStorage($this->sid);
$pailie_video_model = new App_Model_Douyin_MysqlVideoMaterialPailieStorage();
foreach ($video_list as &$item) {
$item['video_num'] = $material_model->getMaterialCountByVideo($item['dv_id'], 1);
$item['audio_num'] = $material_model->getMaterialCountByVideo($item['dv_id'], 2);
$item['image_num'] = $material_model->getMaterialCountByVideo($item['dv_id'], 3);
$item['title_num'] = $material_model->getMaterialCountByVideo($item['dv_id'], 4);
$item['write_num'] = $material_model->getMaterialCountByVideo($item['dv_id'], 5);
$item['cache_num'] = $temp_video_model->getTempVideoCountByItem($item['dv_id']);
$item['pailie'] = $pailie_video_model->getRowByDvid($item['dv_id']);
$progerss = 40;
if ($item['video_num'] > 0 || $item['image_num'] > 0) {
$progerss += 10;
$this->output['add_time_range'] = $add_time_range;
$this->output['keyword_type'] = $keyword_type;
$this->output['keyword'] = $keyword;
$this->output['video_list'] = $video_list;
$this->output['pageHtml'] = $pageHtml;
$video_mixed_mode = plum_parse_config('project_mixed_mode', 'dydqt/project');
$this->output['video_mixed_mode'] = $video_mixed_mode;
$this->output['progress_line'] = [
}
$video_meta_model->deleteById($item['dvm_id']);
}
}
}
$this->showAjaxResult($ret, '修改');
}
/*
* 素材类型输出
*/
private function output_materail_type($da_id, $type, $video_mode){
$material_model = new App_Model_Douyin_MysqlVideoMaterialStorage($this->sid);
$template_model = new App_Model_Douyin_MysqlVideoTempVideoStorage($this->sid);
$temp_video_count = $template_model->getTempVideoCountByItem($da_id);
$type_list = [
'video' => [
'type' => 1,
'title' => '视频素材('.($material_model->getMaterialCountByVideo($da_id, 1)).')',
'url' => "/dydqtshoppc/video/materialList?dv_id={$da_id}&type=1",
],
'image' => [
'type' => 3,
'title' => '图片素材('.($material_model->getMaterialCountByVideo($da_id, 3)).')',
'url' => "/dydqtshoppc/video/materialList?dv_id={$da_id}&type=3",
],
'audio' => [
'type' => 2,
'title' => '音频素材('.($material_model->getMaterialCountByVideo($da_id, 2)).')',
'url' => "/dydqtshoppc/video/materialList?dv_id={$da_id}&type=2",
],
'title' => [
'type' => 4,
'title' => '标题素材('.($material_model->getMaterialCountByVideo($da_id, 4)).')',
'url' => "/dydqtshoppc/video/materialList?dv_id={$da_id}&type=4",
],
'write' => [
'type' => 5,
'title' => '文案素材('.($material_model->getMaterialCountByVideo($da_id, 5)).')',
'url' => "/dydqtshoppc/video/materialList?dv_id={$da_id}&type=5",
],
/*
'dubin' => [
'type' => 6,
'title' => '配音选择',
'url' => "/dydqtshoppc/video/materialList?dv_id={$da_id}&type=6",
],
*/
'background' => [
'type' => 7,
'title' => '背景选择('.($material_model->getMaterialCountByVideo($da_id, 7)).')',
'url' => "/dydqtshoppc/video/materialList?dv_id={$da_id}&type=7",
],
'mixcut' => [
'type' => 0,
'title' => 'AI混剪视频('.($temp_video_count).')',