zhangyong hai 4 meses
pai
achega
3b15e366a8
Modificáronse 2 ficheiros con 24 adicións e 23 borrados
  1. 22 23
      job_keyword_dy.py
  2. 2 0
      video_rewriting/video_processor.py

+ 22 - 23
job_keyword_dy.py

@@ -10,31 +10,30 @@ from video_rewriting.video_processor import VideoProcessor
 def video_task_start():
 def video_task_start():
     """抖视频搜索处理视频任务,返回用户名并根据结果决定延迟时间"""
     """抖视频搜索处理视频任务,返回用户名并根据结果决定延迟时间"""
     data = Material.feishu_list()[14]
     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}")
-                    time.sleep(100)
-                    continue
-            print("开始执行任务")
-            mark = VideoProcessor.main(data)
-            print(f"返回用户名: {mark}")
-            time.sleep(5)
-            continue
-        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}")
+                time.sleep(100)
+                return
+        print("开始执行任务")
+        mark = VideoProcessor.main(data)
+        print(f"返回用户名: {mark}")
+        time.sleep(5)
+        return
+    except Exception as e:
+        print("处理任务时出现异常:", e)
+        time.sleep(10)
+        return
 def schedule_tasks():
 def schedule_tasks():
     schedule.every(6).minutes.do(video_task_start)
     schedule.every(6).minutes.do(video_task_start)
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     video_task_start()
     video_task_start()
-    # schedule_tasks()  # 调用任务调度函数
-    # while True:
-    #     schedule.run_pending()
-    #     time.sleep(1)  # 每秒钟检查一次
+    schedule_tasks()  # 调用任务调度函数
+    while True:
+        schedule.run_pending()
+        time.sleep(1)  # 每秒钟检查一次

+ 2 - 0
video_rewriting/video_processor.py

@@ -134,6 +134,7 @@ class VideoProcessor:
                 return
                 return
             Common.logger(mark).info(f"{name}的{task_mark}下的ID{url} 获取视频完成,共{len(data_list)}条")
             Common.logger(mark).info(f"{name}的{task_mark}下的ID{url} 获取视频完成,共{len(data_list)}条")
             for video in data_list:
             for video in data_list:
+                print("开始改造")
                 cls.remove_files(mark)
                 cls.remove_files(mark)
                 file_path = cls.create_folders(mark)
                 file_path = cls.create_folders(mark)
                 new_title = cls.generate_title(video, title)
                 new_title = cls.generate_title(video, title)
@@ -263,6 +264,7 @@ class VideoProcessor:
                 # 上传视频和封面,并更新数据库
                 # 上传视频和封面,并更新数据库
                 code = cls.upload_video_and_thumbnail(video_path, cover, v_id, new_title, task_mark, name, piaoquan_id,
                 code = cls.upload_video_and_thumbnail(video_path, cover, v_id, new_title, task_mark, name, piaoquan_id,
                                                    file_path, mark, channel_id, url, old_title, rule, video)
                                                    file_path, mark, channel_id, url, old_title, rule, video)
+                print("改造成功")
                 # 更新已使用的视频号状态
                 # 更新已使用的视频号状态
                 pq_url = f'https://admin.piaoquantv.com/cms/post-detail/{code}/detail'  # 站内视频链接
                 pq_url = f'https://admin.piaoquantv.com/cms/post-detail/{code}/detail'  # 站内视频链接
                 if name == "单点视频":
                 if name == "单点视频":