zhangyong 9 mesi fa
parent
commit
689c7aadb9
3 ha cambiato i file con 35 aggiunte e 32 eliminazioni
  1. 1 1
      data_channel/douyin.py
  2. 32 29
      data_channel/kuaishou.py
  3. 2 2
      video_rewriting/video_prep.py

+ 1 - 1
data_channel/douyin.py

@@ -19,7 +19,7 @@ class DY:
         next_cursor = 0
         for i in range(3):
             cookie = Material.get_cookie_data(feishu_id, cookie_sheet, channel_id)
-            time.sleep(random.randint(5, 10))
+            time.sleep(random.randint(1, 5))
             url = 'https://www.douyin.com/aweme/v1/web/aweme/post/'
             headers = {
                 'Accept': 'application/json, text/plain, */*',

+ 32 - 29
data_channel/kuaishou.py

@@ -43,7 +43,7 @@ class KS:
 
         for i in range(3):
             cookie = Material.get_cookie_data(feishu_id, cookie_sheet, channel_id)
-            time.sleep(random.randint(5, 10))
+            time.sleep(random.randint(1, 5))
             payload = json.dumps({
                 "operationName": "visionProfilePhotoList",
                 "variables": {
@@ -88,37 +88,40 @@ class KS:
                 continue
             pcursor = response.json()['data']['visionProfilePhotoList']['pcursor']
             feeds = response.json()['data']['visionProfilePhotoList']['feeds']
-            for i in range(len(feeds)):
-                try:
-                    video_id = feeds[i].get("photo", {}).get("videoResource").get("h264", {}).get("videoId", "")
-                except KeyError:
-                    video_id = feeds[i].get("photo", {}).get("videoResource").get("hevc", {}).get("videoId", "")
-                status = sqlCollect.is_used(task_mark, video_id, mark, channel_id)
-                if status:
-                    video_id = feeds[i].get("photo", {}).get("id", "")
+            try:
+                for i in range(len(feeds)):
+                    try:
+                        video_id = feeds[i].get("photo", {}).get("videoResource").get("h264", {}).get("videoId", "")
+                    except KeyError:
+                        video_id = feeds[i].get("photo", {}).get("videoResource").get("hevc", {}).get("videoId", "")
                     status = sqlCollect.is_used(task_mark, video_id, mark, channel_id)
                     if status:
-                        share_count = cls.get_share_count(video_id)
-                        old_title = feeds[i].get("photo", {}).get("caption")
-                        cover_url = feeds[i].get('photo', {}).get('coverUrl', "")
-                        video_url = feeds[i].get('photo', {}).get('photoUrl', "")
-                        view_count = int(feeds[i].get('photo', {}).get('viewCount', 0))
-                        realLikeCount = int(feeds[i].get('photo', {}).get('realLikeCount', 0))
-                        video_percent = '%.4f' % (share_count / view_count)
-                        duration = dataHelp.video_duration(video_url)
-                        Common.logger("ks").info(
-                            f"扫描:{task_mark},用户主页id:{url_id},视频id{video_id} ,播放数:{view_count} ,分享数:{share_count},时长:{duration} ")
-                        special = float(0.001)
-                        if float(video_percent) < special or share_count < 500 or duration < 30 or duration > 720:
+                        video_id = feeds[i].get("photo", {}).get("id", "")
+                        status = sqlCollect.is_used(task_mark, video_id, mark, channel_id)
+                        if status:
+                            share_count = cls.get_share_count(video_id)
+                            old_title = feeds[i].get("photo", {}).get("caption")
+                            cover_url = feeds[i].get('photo', {}).get('coverUrl', "")
+                            video_url = feeds[i].get('photo', {}).get('photoUrl', "")
+                            view_count = int(feeds[i].get('photo', {}).get('viewCount', 0))
+                            realLikeCount = int(feeds[i].get('photo', {}).get('realLikeCount', 0))
+                            video_percent = '%.4f' % (share_count / view_count)
+                            duration = dataHelp.video_duration(video_url)
                             Common.logger("ks").info(
-                                f"不符合规则:{task_mark},用户主页id:{url_id},视频id{video_id} ,播放数:{view_count} ,分享数:{share_count},时长:{duration} ")
-                            continue
-                        all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": video_percent, "old_title": old_title}
-                        list.append(all_data)
-                        if len(list) == int(number):
-                            Common.logger("log").info(f"获取快手视频总数:{len(list)}\n")
-                            return list
-
+                                f"扫描:{task_mark},用户主页id:{url_id},视频id{video_id} ,播放数:{view_count} ,分享数:{share_count},时长:{duration} ")
+                            special = float(0.001)
+                            if float(video_percent) < special or share_count < 500 or duration < 30 or duration > 720:
+                                Common.logger("ks").info(
+                                    f"不符合规则:{task_mark},用户主页id:{url_id},视频id{video_id} ,播放数:{view_count} ,分享数:{share_count},时长:{duration} ")
+                                continue
+                            all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": video_percent, "old_title": old_title}
+                            list.append(all_data)
+                            if len(list) == int(number):
+                                Common.logger("log").info(f"获取快手视频总数:{len(list)}\n")
+                                return list
+            except Exception as exc:
+                Common.logger("warning").warning(f"{name}的快手获取数据失败:{exc}\n")
+                return list
         return list
 
 if __name__ == '__main__':

+ 2 - 2
video_rewriting/video_prep.py

@@ -88,12 +88,12 @@ class getVideo:
             piaoquan_id = str(task["piaoquan_id"])
             number = task["number"]  # 指定条数
             title = task["title"]
-            video_share_name = task["video_share"]
+            video_share = task["video_share"]
             video_ending = task["video_ending"]
             crop_total = task["crop_total"]
             gg_duration_total = task["gg_duration_total"]
             video_path_url = cls.create_folders(mark, str(task_mark))  # 创建目录
-            zm = Material.get_pzsrt_data("summary", pz_sheet, video_share_name)  # 获取srt
+            zm = Material.get_pzsrt_data("summary", pz_sheet, video_share)  # 获取srt
             if zm == '':
                 Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务下片中标示填写错误,请关注!!!!', name)
             if ',' in channel_urls: