zhangyong пре 1 година
родитељ
комит
0f803a61a8
2 измењених фајлова са 62 додато и 63 уклоњено
  1. 31 32
      main.py
  2. 31 31
      video_stitching/video_stitching.py

+ 31 - 32
main.py

@@ -10,35 +10,34 @@ from common.db import MysqlHelper
 from video_capture.douyin.douyin_author.douyin_author import douyinAuthor
 from video_stitching.video_stitching import VideoStitching
 from datetime import datetime, timedelta
-#
-# def get_count():
-#     current_time = datetime.now()
-#     previous_time = current_time - timedelta(minutes=10)
-#     previous_time_str = previous_time.strftime("%Y-%m-%d %H:%M")
-#     select_user_sql = f"""select video_id from video_url where time >="{previous_time_str}";"""
-#     count = MysqlHelper.get_values(select_user_sql, "prod")
-#     if count:
-#         return True
-#     else:
-#         return False
-#
-# def check_token():
-#     while True:
-#         count = get_count()
-#         if count:
-#             time.sleep(1200)  # 每20分钟检查一次
-#         else:
-#             douyinAuthor.get_token()
-#
-# # 创建并启动线程
-# token_thread = threading.Thread(target=check_token)
-# token_thread.start()
-#
-# # 每天下午4点定时启动 video_stitching 方法
-# schedule.every().day.at("16:00").do(functools.partial())
-#
-#
-# while True:
-#     schedule.run_pending()
-#     time.sleep(1)
-VideoStitching.video_stitching()
+
+def get_count():
+    current_time = datetime.now()
+    previous_time = current_time - timedelta(minutes=10)
+    previous_time_str = previous_time.strftime("%Y-%m-%d %H:%M")
+    select_user_sql = f"""select video_id from video_url where time >="{previous_time_str}";"""
+    count = MysqlHelper.get_values(select_user_sql, "prod")
+    if count:
+        return True
+    else:
+        return False
+
+def check_token():
+    while True:
+        count = get_count()
+        if count:
+            time.sleep(1200)  # 每20分钟检查一次
+        else:
+            douyinAuthor.get_token()
+
+# 创建并启动线程
+token_thread = threading.Thread(target=check_token)
+token_thread.start()
+
+# 每天下午4点定时启动 video_stitching 方法
+schedule.every().day.at("16:00").do(functools.partial(VideoStitching.video_stitching()))
+
+
+while True:
+    schedule.run_pending()
+    time.sleep(1)

+ 31 - 31
video_stitching/video_stitching.py

@@ -84,36 +84,36 @@ class VideoStitching():
     @classmethod
     def insert_piaoquantv(cls, oss_object_key):
         code = 1
-        # list = ["66481136", "66481137", "66481140", "66481141", "66481142"]
-        # for item in list:
-        title = Material.get_title()
-        url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
-        payload = dict(pageSource='vlog-pages/post/post-video-post', videoPath=oss_object_key, width='720',
-                       height='1280', fileExtensions='mp4', viewStatus='1', title=title, careModelStatus='1',
-                       token='f04f58d6e664cbc9902660a1e8d20ce6cd7fdb0f', loginUid="66425096", versionCode='719',
-                       machineCode='weixin_openid_o0w175aZ4FJtqVsA1tcozJDJHdDU', appId='wx89e7eb06478361d7',
-                       clientTimestamp='1703337579331',
-                       machineInfo='{"sdkVersion":"3.2.5","brand":"iPhone","language":"zh_CN","model":"iPhone 12 Pro<iPhone13,3>","platform":"ios","system":"iOS 15.6.1","weChatVersion":"8.0.44","screenHeight":844,"screenWidth":390,"pixelRatio":3,"windowHeight":762,"windowWidth":390,"softVersion":"4.1.719"}',
-                       sessionId='1703337560040-27bfe208-a389-f476-db1d-840681e04b32',
-                       subSessionId='1703337569952-8f56d53c-b36d-760e-8abe-0b4a027cd5bd', senceType='1089',
-                       hotSenceType='1089', id='1050', channel='pq')
-
-        payload['videoPath'] = oss_object_key
-        payload['title'] = title
-
-        data = urllib.parse.urlencode(payload)
-
-        headers = {
-            'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.44(0x18002c2d) NetType/WIFI Language/zh_CN',
-            'Accept-Encoding': 'gzip,compress,br,deflate',
-            'Referer': 'https://servicewechat.com/wx89e7eb06478361d7/726/page-frame.html',
-            'Content-Type': 'application/x-www-form-urlencoded',
-            'Cookie': 'JSESSIONID=A60D96E7A300A25EA05425B069C8B459'
-        }
-
-        response = requests.post(url, data=data, headers=headers)
-        data = response.json()
-        code = data["code"]
+        list = ["66481136", "66481137", "66481140", "66481141", "66481142"]
+        for item in list:
+            title = Material.get_title()
+            url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
+            payload = dict(pageSource='vlog-pages/post/post-video-post', videoPath=oss_object_key, width='720',
+                           height='1280', fileExtensions='mp4', viewStatus='1', title=title, careModelStatus='1',
+                           token='f04f58d6e664cbc9902660a1e8d20ce6cd7fdb0f', loginUid=item, versionCode='719',
+                           machineCode='weixin_openid_o0w175aZ4FJtqVsA1tcozJDJHdDU', appId='wx89e7eb06478361d7',
+                           clientTimestamp='1703337579331',
+                           machineInfo='{"sdkVersion":"3.2.5","brand":"iPhone","language":"zh_CN","model":"iPhone 12 Pro<iPhone13,3>","platform":"ios","system":"iOS 15.6.1","weChatVersion":"8.0.44","screenHeight":844,"screenWidth":390,"pixelRatio":3,"windowHeight":762,"windowWidth":390,"softVersion":"4.1.719"}',
+                           sessionId='1703337560040-27bfe208-a389-f476-db1d-840681e04b32',
+                           subSessionId='1703337569952-8f56d53c-b36d-760e-8abe-0b4a027cd5bd', senceType='1089',
+                           hotSenceType='1089', id='1050', channel='pq')
+
+            payload['videoPath'] = oss_object_key
+            payload['title'] = title
+
+            data = urllib.parse.urlencode(payload)
+
+            headers = {
+                'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.44(0x18002c2d) NetType/WIFI Language/zh_CN',
+                'Accept-Encoding': 'gzip,compress,br,deflate',
+                'Referer': 'https://servicewechat.com/wx89e7eb06478361d7/726/page-frame.html',
+                'Content-Type': 'application/x-www-form-urlencoded',
+                'Cookie': 'JSESSIONID=A60D96E7A300A25EA05425B069C8B459'
+            }
+
+            response = requests.post(url, data=data, headers=headers)
+            data = response.json()
+            code = data["code"]
         if code == 0:
             return True
         else:
@@ -303,7 +303,7 @@ class VideoStitching():
                 except Exception as e:
                     Common.logger().warning(f"新拼接视频发送oss失败:{e}\n")
                     continue
-            if count >= 1:
+            if count >= 20:
                 break