zhangyong 1 year ago
parent
commit
6d3779727e
2 changed files with 9 additions and 4 deletions
  1. 1 1
      main.py
  2. 8 3
      video_stitching/video_stitching.py

+ 1 - 1
main.py

@@ -18,7 +18,7 @@ def job_douyin_data():
 schedule.every().day.at("14:00").do(job_douyin_data)
 
 # 设置上午4点运行任务
-schedule.every().day.at("13:20").do(job_video_stitching)
+schedule.every().day.at("04:00").do(job_video_stitching)
 
 while True:
     schedule.run_pending()

+ 8 - 3
video_stitching/video_stitching.py

@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 # @Time: 2023/12/26
 import datetime
+import gc
 import random
 import os
 import sys
@@ -273,6 +274,7 @@ class VideoStitching():
     def video_stitching(cls, cookie):
         count = 0
         while True:
+            time.sleep(10)
             # 获取音频
             audioid = Material.get_audio()
             # 获取已入库的用户id
@@ -317,18 +319,21 @@ class VideoStitching():
                         Common.logger().info(f"文件不存在{output_path}")
                     piaoquantv = cls.insert_piaoquantv(oss_object_key)
                     if piaoquantv:
-                        time.sleep(120)
                         count += 1
                         Common.logger().info(f"视频添加到对应用户成功")
 
-                        if count >= 5:
+                        if count >= 20:
                             break
+                        time.sleep(180)
+                        Common.logger().info(f"等待3分钟")
                         # 释放视频对象
                         video_with_subtitles.close()
+                        gc.collect()  # 手动回收垃圾
+
             except Exception as e:
                 Common.logger().warning(f"新拼接视频发送oss失败:{e}\n")
                 continue
-            if count >= 5:
+            if count >= 20:
                 break
 
     @classmethod