瀏覽代碼

增加随机选择用户

zhangyong 1 年之前
父節點
當前提交
fecb3cadee
共有 2 個文件被更改,包括 15 次插入10 次删除
  1. 3 1
      main.py
  2. 12 9
      video_stitching/video_stitching.py

+ 3 - 1
main.py

@@ -18,9 +18,11 @@ def job_douyin_data():
 schedule.every().day.at("12:00").do(job_douyin_data)
 
 # 设置下午4点运行任务
-schedule.every().day.at("17:25").do(job_video_stitching)
+schedule.every().day.at("19:05").do(job_video_stitching)
 
 while True:
     schedule.run_pending()
     time.sleep(1)
 
+
+

+ 12 - 9
video_stitching/video_stitching.py

@@ -73,12 +73,12 @@ class VideoStitching():
 
 
     @classmethod
-    def get_url_list(cls, i, account):
+    def get_url_list(cls, audio_id, account):
         url_list = f"""SELECT a.video_id,a.account_id,a.oss_object_key FROM video_url a WHERE NOT EXISTS (
                 SELECT video_id
                 FROM video_audio b
-                WHERE a.video_id = b.video_id AND b.audio = "{i}"
-            ) AND a.account_id = '{account}' ;"""
+                WHERE a.video_id = b.video_id AND b.audio = "{audio_id}"
+            ) AND a.account_id = {account} ;"""
         url_list = MysqlHelper.get_values(url_list, "prod")
         return url_list
 
@@ -269,14 +269,16 @@ class VideoStitching():
     @classmethod
     def video_stitching(cls, cookie):
         count = 0
-        # 获取音频
-        audio_id = Material.get_audio()
+
         while True:
+            # 获取音频
+            audioid = Material.get_audio()
             # 获取已入库的用户id
             account_id = cls.get_account_id()
-            audio_id = random.choice(audio_id)
-            for j in account_id:
-                account = j[0].replace('(', '').replace(')', '').replace(',', '')
+            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)
@@ -314,6 +316,7 @@ class VideoStitching():
                             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:
@@ -321,7 +324,7 @@ class VideoStitching():
                 except Exception as e:
                     Common.logger().warning(f"新拼接视频发送oss失败:{e}\n")
                     continue
-            if count >= 13:
+            if count >= 6:
                 break
 
     @classmethod