zhangyong 4 月之前
父節點
當前提交
b61d61ec0b
共有 1 個文件被更改,包括 16 次插入17 次删除
  1. 16 17
      job_keyword_dy.py

+ 16 - 17
job_keyword_dy.py

@@ -10,23 +10,22 @@ from video_rewriting.video_processor import VideoProcessor
 def video_task_start():
     """抖视频搜索处理视频任务,返回用户名并根据结果决定延迟时间"""
     data = Material.feishu_list()[14]
-    while True:
-        try:
-            count = sqlCollect.get_channel_count("抖音搜索", "品类关键词搜索")
-            count = int(count[0][0])
-            sheet_count = Material.get_count_restrict("抖音关键词搜索")
-            if sheet_count:
-                if count >= int(sheet_count):
-                    print(f"到了限制数{count}")
-                    return
-            print("开始执行任务")
-            mark = VideoProcessor.main(data)
-            print(f"返回用户名: {mark}")
-            # time.sleep(10 if mark else 120)  # 根据 mark 是否为空设置延迟
-        except Exception as e:
-            print("处理任务时出现异常:", e)
-            time.sleep(10)
-            continue
+    try:
+        count = sqlCollect.get_channel_count("抖音搜索", "品类关键词搜索")
+        count = int(count[0][0])
+        sheet_count = Material.get_count_restrict("抖音关键词搜索")
+        if sheet_count:
+            if count >= int(sheet_count):
+                print(f"到了限制数{count}")
+                return
+        print("开始执行任务")
+        mark = VideoProcessor.main(data)
+        print(f"返回用户名: {mark}")
+        # time.sleep(10 if mark else 120)  # 根据 mark 是否为空设置延迟
+    except Exception as e:
+        print("处理任务时出现异常:", e)
+        time.sleep(10)
+        return
 def schedule_tasks():
     schedule.every(10).minutes.do(video_task_start)
 if __name__ == '__main__':