|
@@ -269,62 +269,60 @@ class VideoStitching():
|
|
|
@classmethod
|
|
|
def video_stitching(cls, cookie):
|
|
|
count = 0
|
|
|
-
|
|
|
while True:
|
|
|
# 获取音频
|
|
|
audioid = Material.get_audio()
|
|
|
# 获取已入库的用户id
|
|
|
account_id = cls.get_account_id()
|
|
|
audio_id = random.choice(audioid)
|
|
|
- for i in range(len(account_id)):
|
|
|
- account = random.choice(account_id)
|
|
|
- account = str(account).replace('(', '').replace(')', '').replace(',', '')
|
|
|
- Common.logger().info(f"获取用户ID:{account}")
|
|
|
- # 获取 未使用的视频链接
|
|
|
- url_list = cls.get_url_list(audio_id, account)
|
|
|
- # 获取音频url
|
|
|
- audio = cls.get_audio_url(audio_id, cookie)
|
|
|
- if audio == "":
|
|
|
- continue
|
|
|
- Common.logger().info(f"获取音频地址:{audio}")
|
|
|
- videos = [list(item) for item in url_list]
|
|
|
- videos = Oss.get_oss_url(videos)
|
|
|
- # 视频截取
|
|
|
- try:
|
|
|
- audio_url = cls.concatenate_videos(videos, str(audio), audio_id)
|
|
|
- if len(audio_url) == 0:
|
|
|
- Common.logger().info(f"视频生成失败")
|
|
|
- continue
|
|
|
- # 随机生成视频id
|
|
|
- id = cls.random_id()
|
|
|
- Common.logger().info(f"生成视频id为:{id}")
|
|
|
- # 上传 oss
|
|
|
- oss_object_key = Oss.stitching_sync_upload_oss(output_path, id)
|
|
|
- status = oss_object_key.get("status")
|
|
|
- # 获取 oss 视频地址
|
|
|
- oss_object_key = oss_object_key.get("oss_object_key")
|
|
|
- Common.logger().info(f"新拼接视频,oss发送成功,oss地址:{oss_object_key}")
|
|
|
- if status == 200:
|
|
|
- time.sleep(10)
|
|
|
- # 发送成功 已使用视频存入数据库
|
|
|
- cls.insert_videoAudio(audio_url, audio)
|
|
|
- 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)
|
|
|
- if piaoquantv:
|
|
|
- time.sleep(360)
|
|
|
- count += 1
|
|
|
- Common.logger().info(f"视频添加到对应用户成功")
|
|
|
- if count >= 20:
|
|
|
- break
|
|
|
- except Exception as e:
|
|
|
- Common.logger().warning(f"新拼接视频发送oss失败:{e}\n")
|
|
|
+ account = random.choice(account_id)
|
|
|
+ account = str(account).replace('(', '').replace(')', '').replace(',', '')
|
|
|
+ Common.logger().info(f"获取用户ID:{account}")
|
|
|
+ # 获取 未使用的视频链接
|
|
|
+ url_list = cls.get_url_list(audio_id, account)
|
|
|
+ # 获取音频url
|
|
|
+ audio = cls.get_audio_url(audio_id, cookie)
|
|
|
+ if audio == "":
|
|
|
+ continue
|
|
|
+ Common.logger().info(f"获取音频地址:{audio}")
|
|
|
+ videos = [list(item) for item in url_list]
|
|
|
+ videos = Oss.get_oss_url(videos)
|
|
|
+ # 视频截取
|
|
|
+ try:
|
|
|
+ audio_url = cls.concatenate_videos(videos, str(audio), audio_id)
|
|
|
+ if len(audio_url) == 0:
|
|
|
+ Common.logger().info(f"视频生成失败")
|
|
|
continue
|
|
|
- if count >= 6:
|
|
|
+ # 随机生成视频id
|
|
|
+ id = cls.random_id()
|
|
|
+ Common.logger().info(f"生成视频id为:{id}")
|
|
|
+ # 上传 oss
|
|
|
+ oss_object_key = Oss.stitching_sync_upload_oss(output_path, id)
|
|
|
+ status = oss_object_key.get("status")
|
|
|
+ # 获取 oss 视频地址
|
|
|
+ oss_object_key = oss_object_key.get("oss_object_key")
|
|
|
+ Common.logger().info(f"新拼接视频,oss发送成功,oss地址:{oss_object_key}")
|
|
|
+ if status == 200:
|
|
|
+ time.sleep(10)
|
|
|
+ # 发送成功 已使用视频存入数据库
|
|
|
+ cls.insert_videoAudio(audio_url, audio)
|
|
|
+ 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)
|
|
|
+ if piaoquantv:
|
|
|
+ time.sleep(360)
|
|
|
+ count += 1
|
|
|
+ Common.logger().info(f"视频添加到对应用户成功")
|
|
|
+ if count >= 3:
|
|
|
+ break
|
|
|
+ except Exception as e:
|
|
|
+ Common.logger().warning(f"新拼接视频发送oss失败:{e}\n")
|
|
|
+ continue
|
|
|
+ if count >= 3:
|
|
|
break
|
|
|
|
|
|
@classmethod
|