zhangyong 4 months ago
parent
commit
1bfdfb9d02
3 changed files with 26 additions and 24 deletions
  1. 1 1
      data_channel/piaoquan.py
  2. 23 22
      job_keyword_dy.py
  3. 2 1
      video_rewriting/video_processor.py

+ 1 - 1
data_channel/piaoquan.py

@@ -452,7 +452,7 @@ class PQ:
                     'referer': f'https://www.douyin.com/video/{video_id}',
                     'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
                 }
-                response = requests.request("GET", video_url, headers=headers, data=payload)
+                response = requests.request("GET", video_url, headers=headers, data=payload, timeout= 60)
                 if response.status_code == 206:
                     # 以二进制写入模式打开文件
                     with open(f"{video}", "wb") as file:

+ 23 - 22
job_keyword_dy.py

@@ -10,30 +10,31 @@ from video_rewriting.video_processor import VideoProcessor
 def video_task_start():
     """抖视频搜索处理视频任务,返回用户名并根据结果决定延迟时间"""
     data = Material.feishu_list()[14]
-    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
+    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
 def schedule_tasks():
     schedule.every(6).minutes.do(video_task_start)
 
 if __name__ == '__main__':
     video_task_start()
-    schedule_tasks()  # 调用任务调度函数
-    while True:
-        schedule.run_pending()
-        time.sleep(1)  # 每秒钟检查一次
+    # schedule_tasks()  # 调用任务调度函数
+    # while True:
+    #     schedule.run_pending()
+    #     time.sleep(1)  # 每秒钟检查一次

+ 2 - 1
video_rewriting/video_processor.py

@@ -445,10 +445,11 @@ class VideoProcessor:
                     Feishu.insert_columns("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "ROWS", 1, 2)
                     time.sleep(0.5)
                     Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
-
+                    continue
         except Exception as e:
             AliyunLogger.logging(channel_id, name, url, v_id, f"改造失败{traceback.format_exc()}", "3001")
             Common.logger(mark).error(f"{name}的{task_mark}任务处理失败:{traceback.format_exc()}")
+            return
 
 
     @classmethod