|
@@ -53,11 +53,15 @@ class VideoStitching():
|
|
|
return hours * 3600 + minutes * 60 + seconds
|
|
|
|
|
|
@classmethod
|
|
|
- def insert_videoAudio(cls, audio_url, i):
|
|
|
+ def insert_videoAudio(cls, audio_url, i, channel_type):
|
|
|
current_time = datetime.now()
|
|
|
formatted_time = current_time.strftime("%Y-%m-%d")
|
|
|
+ if channel_type == "douyin":
|
|
|
+ video_type = 0
|
|
|
+ else:
|
|
|
+ video_type = 2
|
|
|
for j in audio_url:
|
|
|
- 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)"""
|
|
|
+ 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}', {video_type})"""
|
|
|
MysqlHelper.update_values(
|
|
|
sql=insert_sql,
|
|
|
env="prod",
|
|
@@ -87,8 +91,8 @@ class VideoStitching():
|
|
|
return id
|
|
|
|
|
|
@classmethod
|
|
|
- def get_account_id(cls):
|
|
|
- account_id = f"""select account_id from video_url group by account_id;"""
|
|
|
+ def get_account_id(cls, channel_type):
|
|
|
+ account_id = f"""select account_id from video_url where oss_object_key LIKE '%{channel_type}%' group by account_id ;"""
|
|
|
account_id = MysqlHelper.get_values(account_id, "prod")
|
|
|
return account_id
|
|
|
|
|
@@ -117,12 +121,15 @@ class VideoStitching():
|
|
|
|
|
|
# 新生成视频上传到对应账号下
|
|
|
@classmethod
|
|
|
- def insert_piaoquantv(cls, oss_object_key, title_list, video_type):
|
|
|
+ def insert_piaoquantv(cls, oss_object_key, title_list, video_type, channel_type):
|
|
|
#list = ["66481136", "66481137", "66481140", "66481141", "66481142"] 老用户id
|
|
|
if video_type == "口播--美文类":
|
|
|
list = ["67231152", "67231153", "67231154", "67231155", "67231157"]
|
|
|
else:
|
|
|
- list = ["67231113", "67231112", "67231111", "67231110", "67231109"]
|
|
|
+ if channel_type == "douyin":
|
|
|
+ list = ["67231113", "67231112", "67231111", "67231110", "67231109"]
|
|
|
+ else:
|
|
|
+ list = ["67413406", "67413407", "67413408", "67413409", "67413410"]
|
|
|
code = 1
|
|
|
for i in range(2):
|
|
|
item = random.choice(list)
|
|
@@ -318,10 +325,10 @@ class VideoStitching():
|
|
|
return ""
|
|
|
|
|
|
@classmethod
|
|
|
- def video_stitching(cls, video_type, count):
|
|
|
+ def video_stitching(cls, video_type, count, channel_type):
|
|
|
cookie = Material.get_houtai_cookie()
|
|
|
# 获取音频类型+字幕
|
|
|
- audio_id, srt, title_list = Material.get_audio_type(video_type, count)
|
|
|
+ audio_id, srt, title_list = Material.get_audio_type(video_type, count, channel_type)
|
|
|
if video_type == "口播--美文类":
|
|
|
# 获取已入库的口播视频
|
|
|
audio_list = cls.get_audio_list()
|
|
@@ -334,7 +341,7 @@ class VideoStitching():
|
|
|
return
|
|
|
else:
|
|
|
# 获取已入库的用户id
|
|
|
- account_id = cls.get_account_id()
|
|
|
+ account_id = cls.get_account_id(channel_type)
|
|
|
account = random.choice(account_id)
|
|
|
account = str(account).replace('(', '').replace(')', '').replace(',', '')
|
|
|
Common.logger().info(f"获取用户ID:{account}")
|
|
@@ -371,14 +378,14 @@ class VideoStitching():
|
|
|
if video_type == "口播--美文类":
|
|
|
cls.insert_video_typeAudio(videos[0], audio_id)
|
|
|
else:
|
|
|
- cls.insert_videoAudio(audio_url, audio_id)
|
|
|
+ cls.insert_videoAudio(audio_url, audio_id, channel_type)
|
|
|
Common.logger().info(f"发送成功 已使用视频存入数据库完成")
|
|
|
if os.path.isfile(output_path):
|
|
|
os.remove(output_path)
|
|
|
Common.logger().info(f"文件删除成功{output_path}")
|
|
|
else:
|
|
|
Common.logger().info(f"文件不存在{output_path}")
|
|
|
- piaoquantv = cls.insert_piaoquantv(oss_object_key, title_list, video_type)
|
|
|
+ piaoquantv = cls.insert_piaoquantv(oss_object_key, title_list, video_type, channel_type)
|
|
|
if piaoquantv:
|
|
|
Common.logger().info(f"视频添加到对应用户成功")
|
|
|
# 关闭视频文件
|