|
@@ -57,7 +57,7 @@ class VideoStitching():
|
|
current_time = datetime.now()
|
|
current_time = datetime.now()
|
|
formatted_time = current_time.strftime("%Y-%m-%d")
|
|
formatted_time = current_time.strftime("%Y-%m-%d")
|
|
for j in audio_url:
|
|
for j in audio_url:
|
|
- insert_sql = f"""INSERT INTO video_audio (audio, video_id, account_id, oss_object_key, time) values ('{i}', '{j[0]}', '{j[1]}', '{j[2]}', '{formatted_time}')"""
|
|
|
|
|
|
+ insert_sql = f"""INSERT INTO video_audio (audio, video_id, account_id, oss_object_key, time, video_type) values ('{i}', '{j[0]}', '{j[1]}', '{j[2]}', '{formatted_time}', 0)"""
|
|
MysqlHelper.update_values(
|
|
MysqlHelper.update_values(
|
|
sql=insert_sql,
|
|
sql=insert_sql,
|
|
env="prod",
|
|
env="prod",
|
|
@@ -70,7 +70,7 @@ class VideoStitching():
|
|
def insert_video_typeAudio(cls, video, audio_id):
|
|
def insert_video_typeAudio(cls, video, audio_id):
|
|
current_time = datetime.now()
|
|
current_time = datetime.now()
|
|
formatted_time = current_time.strftime("%Y-%m-%d")
|
|
formatted_time = current_time.strftime("%Y-%m-%d")
|
|
- insert_sql = f"""INSERT INTO video_audio (audio, account_id, oss_object_key, time) values ('{audio_id}', '{video}', '{video}', '{formatted_time}')"""
|
|
|
|
|
|
+ insert_sql = f"""INSERT INTO video_audio (audio, account_id, oss_object_key, time, video_type) values ('{audio_id}', '{video}', '{video}', '{formatted_time}', 1)"""
|
|
MysqlHelper.update_values(
|
|
MysqlHelper.update_values(
|
|
sql=insert_sql,
|
|
sql=insert_sql,
|
|
env="prod",
|
|
env="prod",
|
|
@@ -117,9 +117,13 @@ class VideoStitching():
|
|
|
|
|
|
# 新生成视频上传到对应账号下
|
|
# 新生成视频上传到对应账号下
|
|
@classmethod
|
|
@classmethod
|
|
- def insert_piaoquantv(cls, oss_object_key, title_list):
|
|
|
|
|
|
+ def insert_piaoquantv(cls, oss_object_key, title_list, video_type):
|
|
|
|
+ #list = ["66481136", "66481137", "66481140", "66481141", "66481142"] 老用户id
|
|
|
|
+ if video_type == "口播--美文类":
|
|
|
|
+ list = ["67231152", "67231153", "67231154", "67231155", "67231157"]
|
|
|
|
+ else:
|
|
|
|
+ list = ["67231113", "67231112", "67231111", "67231110", "67231109"]
|
|
code = 1
|
|
code = 1
|
|
- list = ["66481136", "66481137", "66481140", "66481141", "66481142"]
|
|
|
|
for i in range(2):
|
|
for i in range(2):
|
|
item = random.choice(list)
|
|
item = random.choice(list)
|
|
title_list = [item for item in title_list if item is not None]
|
|
title_list = [item for item in title_list if item is not None]
|
|
@@ -314,11 +318,11 @@ class VideoStitching():
|
|
return ""
|
|
return ""
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
- def video_stitching(cls):
|
|
|
|
|
|
+ def video_stitching(cls, video_type):
|
|
cookie = Material.get_houtai_cookie()
|
|
cookie = Material.get_houtai_cookie()
|
|
# 获取音频类型+字幕
|
|
# 获取音频类型+字幕
|
|
- audio_id, srt, title_list, type_audio = Material.get_audio_type()
|
|
|
|
- if type_audio == "口播--美文类":
|
|
|
|
|
|
+ audio_id, srt, title_list = Material.get_audio_type(video_type)
|
|
|
|
+ if video_type == "口播--美文类":
|
|
# 获取已入库的口播视频
|
|
# 获取已入库的口播视频
|
|
audio_list = cls.get_audio_list()
|
|
audio_list = cls.get_audio_list()
|
|
videos = [list(item) for item in audio_list]
|
|
videos = [list(item) for item in audio_list]
|
|
@@ -326,7 +330,7 @@ class VideoStitching():
|
|
# 判断该视频+音频是否生成过视频
|
|
# 判断该视频+音频是否生成过视频
|
|
video = VideoStitching.get_audio_url_list(videos, audio_id)
|
|
video = VideoStitching.get_audio_url_list(videos, audio_id)
|
|
if video:
|
|
if video:
|
|
- Common.logger().info(f"该该视频+音频已经生成过视频,不做视频拼接")
|
|
|
|
|
|
+ Common.logger().info(f"该视频+音频已经生成过视频,不做视频拼接")
|
|
return
|
|
return
|
|
else:
|
|
else:
|
|
# 获取已入库的用户id
|
|
# 获取已入库的用户id
|
|
@@ -349,7 +353,7 @@ class VideoStitching():
|
|
# videos = Oss.get_oss_url(videos)
|
|
# videos = Oss.get_oss_url(videos)
|
|
# 视频截取
|
|
# 视频截取
|
|
try:
|
|
try:
|
|
- audio_url, video_with_subtitles, clips = cls.concatenate_videos(videos, str(audio), srt, type_audio)
|
|
|
|
|
|
+ audio_url, video_with_subtitles, clips = cls.concatenate_videos(videos, str(audio), srt, video_type)
|
|
if len(audio_url) == 0:
|
|
if len(audio_url) == 0:
|
|
Common.logger().info(f"视频生成失败")
|
|
Common.logger().info(f"视频生成失败")
|
|
# 随机生成视频id
|
|
# 随机生成视频id
|
|
@@ -364,7 +368,7 @@ class VideoStitching():
|
|
if status == 200:
|
|
if status == 200:
|
|
time.sleep(10)
|
|
time.sleep(10)
|
|
# 发送成功 已使用视频存入数据库
|
|
# 发送成功 已使用视频存入数据库
|
|
- if type_audio == "口播--美文类":
|
|
|
|
|
|
+ if video_type == "口播--美文类":
|
|
cls.insert_video_typeAudio(videos[0], audio_id)
|
|
cls.insert_video_typeAudio(videos[0], audio_id)
|
|
else:
|
|
else:
|
|
cls.insert_videoAudio(audio_url, audio_id)
|
|
cls.insert_videoAudio(audio_url, audio_id)
|
|
@@ -374,7 +378,7 @@ class VideoStitching():
|
|
Common.logger().info(f"文件删除成功{output_path}")
|
|
Common.logger().info(f"文件删除成功{output_path}")
|
|
else:
|
|
else:
|
|
Common.logger().info(f"文件不存在{output_path}")
|
|
Common.logger().info(f"文件不存在{output_path}")
|
|
- piaoquantv = cls.insert_piaoquantv(oss_object_key, title_list)
|
|
|
|
|
|
+ piaoquantv = cls.insert_piaoquantv(oss_object_key, title_list, video_type)
|
|
if piaoquantv:
|
|
if piaoquantv:
|
|
Common.logger().info(f"视频添加到对应用户成功")
|
|
Common.logger().info(f"视频添加到对应用户成功")
|
|
# 关闭视频文件
|
|
# 关闭视频文件
|
|
@@ -391,6 +395,7 @@ class VideoStitching():
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
- VideoStitching.video_stitching()
|
|
|
|
|
|
+ video_type = "口播--美文类"
|
|
|
|
+ VideoStitching.video_stitching(video_type)
|
|
|
|
|
|
|
|
|