zhangyong 4 ay önce
ebeveyn
işleme
102015e061
2 değiştirilmiş dosya ile 16 ekleme ve 9 silme
  1. 6 6
      data_channel/piaoquan.py
  2. 10 3
      job_keyword_dy.py

+ 6 - 6
data_channel/piaoquan.py

@@ -436,6 +436,7 @@ class PQ:
     @classmethod
     def download_dy_video(cls, video_url, video_path_url, video_id):
         try:
+            video = video_path_url + str(video_id) + '.mp4'
             for i in range(3):
                 payload = {}
                 headers = {
@@ -453,14 +454,14 @@ class PQ:
                 response = requests.request("GET", video_url, headers=headers, data=payload)
                 if response.status_code == 206:
                     # 以二进制写入模式打开文件
-                    video = video_path_url + str(video_id) + '.mp4'
                     with open(f"{video}", "wb") as file:
                         # 将响应内容写入文件
                         file.write(response.content)
                     time.sleep(5)
                     return video
-            return None
-        except Exception:
+            return video
+        except Exception as e:
+            print(e)
             return None
 
     """
@@ -485,7 +486,6 @@ class PQ:
 
 
 if __name__ == '__main__':
-    url= 'http://111.51.148.73/ksc1/55LDHcm2DuGHbBbzIDfqMh-vfVhaCuIXZG0szwmCZj9pXLmq7otQhUyGXtBtc13Rb0C49a4FzRU5xfUaRQb6De46IO6hQBVqzjOkFArRDfTC7u9BThi0Bsa2w6PP_6dg7WQYKxU6ZIbYI2tnLfOXU5Ira-DEZuGDQbgpZstADnGtvLMkOiB6DImlhfgdxWIZ.mp4?tag=1-1724839019-sp-0-lgl7lhkrnt-8937a5c247b0f313&provider=self&ocid=341&clientCacheKey=3x3br4x5z5hew32_bF.mp4&tt=bF&di=6f31a709&bp=10001'
-    video = {"wx_msg": '{"TypeName":"AddMsg","Appid":"wx_GtAew_wmLbsHMbpDe7Hwk","Data":{"MsgId":1176686077,"FromUserName":{"string":"51757111911@chatroom"},"ToUserName":{"string":"wxid_mr9pdsanc99422"},"MsgType":1,"Content":{"string":"wxid_3379403802612:\n6.41 复制打开抖音,看看【Zooey的作品】被一只青蛙问候了?!  https://v.douyin.com/ihHknvbV/ w@f.bA YZm:/ 06/05 "},"Status":3,"ImgStatus":1,"ImgBuf":{"iLen":0},"CreateTime":1725343506,"MsgSource":"<msgsource>\n\t<bizflag>0</bizflag>\n\t<pua>1</pua>\n\t<alnode>\n\t\t<cf>3</cf>\n\t\t<inlenlist>86</inlenlist>\n\t</alnode>\n\t<silence>1</silence>\n\t<membercount>4</membercount>\n\t<signature>V1_pVkC6xlw|v1_pVkC6xlw</signature>\n\t<tmp_node>\n\t\t<publisher-id></publisher-id>\n\t</tmp_node>\n</msgsource>\n","NewMsgId":6473116084228305363,"MsgSeq":776685968},"Wxid":"wxid_mr9pdsanc99422"}'}
-    a = PQ.download_video(url,'/Users/tzld/Desktop/video_rewriting/path','70100016',video,'单点视频')
+    url ='https://v5-dy-o-abtest.zjcdn.com/24958f9e7ef091a31c409c0dd1e83a6f/675fc6bc/video/tos/cn/tos-cn-ve-15/oIB5AwLndiATiANQIziB1TfHED3igPr1AD5Kje/?a=1128&ch=11&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=515&bt=515&cs=0&ds=6&ft=J33IIDDhNF5VQsYesNousauzXzySY~bbUBvThbLfK&mime_type=video_mp4&qs=0&rc=aTg2M2Y3ZjU1NGg3ZTU8aUBpamVoZ285cjh0djMzNGkzM0AxNjIzYjUuNV4xXmFiLTRiYSMwM2FlMmRjY3BgLS1kLTBzcw%3D%3D&btag=80010e000b0001&cc=46&cquery=105E_103Q_103W_103Y_100b&dy_q=1734326142&feature_id=f0150a16a324336cda5d6dd0b69ed299&l=20241216131541780499AB5185B80CA219&req_cdn_type='
+    a = PQ.download_dy_video(url,'/Users/z/Downloads/','70100016')
     print(a)

+ 10 - 3
job_keyword_dy.py

@@ -1,5 +1,8 @@
 
 import time
+
+import schedule
+
 from common import Material
 from common.sql_help import sqlCollect
 
@@ -15,8 +18,7 @@ def video_task_start():
             if sheet_count:
                 if count >= int(sheet_count):
                     print(f"到了限制数{count}")
-                    time.sleep(3600)
-                    continue
+                    return
             print("开始执行任务")
             mark = VideoProcessor.main(data)
             print(f"返回用户名: {mark}")
@@ -25,6 +27,11 @@ def video_task_start():
             print("处理任务时出现异常:", e)
             time.sleep(10)
             continue
+def schedule_tasks():
+    schedule.every(10).minutes.do(video_task_start)
 if __name__ == '__main__':
-    video_task_start()
+    schedule_tasks()  # 调用任务调度函数
+    while True:
+        schedule.run_pending()
+        time.sleep(1)  # 每秒钟检查一次