|
@@ -25,7 +25,7 @@ class AgcVidoe():
|
|
|
@classmethod
|
|
|
def get_url_list(cls, user_list, mark, limit_count):
|
|
|
for i in range(5):
|
|
|
- user = random.choice(user_list)
|
|
|
+ user = str(random.choice(user_list))
|
|
|
if "-" not in mark:
|
|
|
user = user.replace('(', '').replace(')', '').replace(',', '')
|
|
|
current_time = datetime.now()
|
|
@@ -36,8 +36,8 @@ class AgcVidoe():
|
|
|
url_list = f"""SELECT a.video_id,a.account_id,a.oss_object_key FROM agc_video_url a WHERE NOT EXISTS (
|
|
|
SELECT video_id
|
|
|
FROM agc_video_deposit b
|
|
|
- WHERE a.oss_object_key = b.oss_object_key AND b.time == '{formatted_current_time}'
|
|
|
- ) AND a.account_id = '{user}' and a.`status` = 1 and a.mark = '{mark}' limit {limit_count};"""
|
|
|
+ WHERE a.oss_object_key = b.oss_object_key AND b.time = '{formatted_current_time}'
|
|
|
+ ) AND a.account_id = {user} and a.`status` = 1 and a.mark = '{mark}' limit {limit_count};"""
|
|
|
url_list = MysqlHelper.get_values(url_list, "prod")
|
|
|
if url_list:
|
|
|
return url_list
|
|
@@ -46,7 +46,7 @@ class AgcVidoe():
|
|
|
SELECT video_id
|
|
|
FROM agc_video_deposit b
|
|
|
WHERE a.oss_object_key = b.oss_object_key AND b.time >= '{formatted_three_days_ago}' AND b.time <= '{formatted_current_time}'
|
|
|
- ) AND a.account_id = '{user}' and a.`status` = 1 and a.mark = '{mark}' limit {limit_count};"""
|
|
|
+ ) AND a.account_id = {user} and a.`status` = 1 and a.mark = '{mark}' limit {limit_count};"""
|
|
|
url_list = MysqlHelper.get_values(url_list, "prod")
|
|
|
if url_list:
|
|
|
if len(url_list) >= 30:
|
|
@@ -540,7 +540,7 @@ class AgcVidoe():
|
|
|
limit_count = 1
|
|
|
url_list = cls.get_url_list(video_list, mark, limit_count)
|
|
|
if url_list == None:
|
|
|
- Common.logger("video").info(f"{mark}的{platform} 渠道 视频画面不足无法拼接")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform} 渠道 视频画面不足无法拼接")
|
|
|
return
|
|
|
videos = [list(item) for item in url_list]
|
|
|
try:
|
|
@@ -549,21 +549,21 @@ class AgcVidoe():
|
|
|
if srt:
|
|
|
# 创建临时字幕文件
|
|
|
cls.create_subtitle_file(srt, s_path)
|
|
|
- Common.logger("video").info(f"S{mark}的{platform}渠道RT 文件目录创建成功")
|
|
|
+ Common.logger("gs_video").info(f"S{mark}的{platform}渠道RT 文件目录创建成功")
|
|
|
# 获取音频
|
|
|
audio_video, audio_title = cls.get_audio_url(uid, mark, mark_name)
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道获取需要拼接的音频成功")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道获取需要拼接的音频成功")
|
|
|
# 获取音频秒数
|
|
|
audio_duration = cls.get_audio_duration(audio_video)
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道获取需要拼接的音频秒数为:{audio_duration}")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道获取需要拼接的音频秒数为:{audio_duration}")
|
|
|
video_files = cls.concatenate_videos(videos, audio_duration, audio_video, platform, s_path, v_path, mark, v_oss_path)
|
|
|
if video_files == "":
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道使用拼接视频为空")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道使用拼接视频为空")
|
|
|
return ""
|
|
|
if os.path.isfile(v_oss_path):
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道新视频生成成功")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道新视频生成成功")
|
|
|
else:
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道新视频生成失败")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道新视频生成失败")
|
|
|
return ""
|
|
|
# 随机生成视频oss_id
|
|
|
oss_id = cls.random_id()
|
|
@@ -571,26 +571,26 @@ class AgcVidoe():
|
|
|
v_path_duration = cls.get_audio_duration(v_oss_path)
|
|
|
if v_path_duration > audio_duration+3 or v_path_duration < audio_duration-3:
|
|
|
print(f"{mark}的{platform}渠道最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
|
|
|
return ""
|
|
|
# 上传 oss
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道上传到 OSS 生成视频id为:{oss_id}")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道上传到 OSS 生成视频id为:{oss_id}")
|
|
|
oss_object_key = Oss.stitching_sync_upload_oss(v_oss_path, oss_id)
|
|
|
status = oss_object_key.get("status")
|
|
|
if status == 200:
|
|
|
# 获取 oss 视频地址
|
|
|
oss_object_key = oss_object_key.get("oss_object_key")
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道拼接视频发送成功,OSS 地址:{oss_object_key}")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道拼接视频发送成功,OSS 地址:{oss_object_key}")
|
|
|
time.sleep(10)
|
|
|
# 已使用视频存入数据库
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道开始已使用视频存入数据库")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道开始已使用视频存入数据库")
|
|
|
cls.insert_videoAudio(video_files, uid, platform, mark)
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道完成已使用视频存入数据库")
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道开始视频添加到对应用户")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道完成已使用视频存入数据库")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道开始视频添加到对应用户")
|
|
|
piaoquantv = cls.insert_piaoquantv(oss_object_key, audio_title, pq_ids_list)
|
|
|
if piaoquantv:
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道视频添加到对应用户成功")
|
|
|
+ Common.logger("gs_video").info(f"{mark}的{platform}渠道视频添加到对应用户成功")
|
|
|
return ''
|
|
|
except Exception as e:
|
|
|
- Common.logger("video").warning(f"{mark}的视频拼接失败:{e}\n")
|
|
|
+ Common.logger("gs_video").warning(f"{mark}的视频拼接失败:{e}\n")
|
|
|
return ''
|