zhangyong 4 月之前
父節點
當前提交
c435dd37e0
共有 2 個文件被更改,包括 13 次插入15 次删除
  1. 11 14
      data_channel/ks_keyword.py
  2. 2 1
      video_rewriting/video_processor.py

+ 11 - 14
data_channel/ks_keyword.py

@@ -12,7 +12,7 @@ class KsKeyword:
     @classmethod
     def get_key_word(cls, keyword, task_mark, mark, channel_id, name, task):
         combo = task['combo']
-        content_type = combo[0]
+        sort_type = combo[0]
         publish_time = combo[1]
         duration = combo[2]
         share_count_rule = 0
@@ -25,8 +25,8 @@ class KsKeyword:
             return list
         payload = json.dumps({
             "keyword": keyword,
-            "content_type": content_type,
-            "sort_type": "视频",
+            "content_type": "综合",
+            "sort_type": sort_type,
             "publish_time": publish_time,
             "duration": duration,
             "cursor": ""
@@ -64,23 +64,20 @@ class KsKeyword:
                 return list
             data_list = response['data']['data']
             for data in data_list:
-                type = int(data['type'])
-                if type != 1:
-                    continue
-                photo_type = data['photoType']
-                if photo_type != "VIDEO":
-                    continue
-                photo_id =  data['photoId']
+                data = data['feed']
+                photo_id =  data['photo_id']
                 day_count = Material.get_count_restrict(channel_id)
                 if day_count:
                     status = sqlCollect.is_used_days(task_mark, photo_id, mark, channel_id, day_count)
                 else:
                     status = sqlCollect.is_used(task_mark, photo_id, mark, channel_id)
 
-                image_url = data['webpCoverUrls'][0]['url']
-                video_url = data['mainMvUrls'][0]['url']
-                view_count = data.get('viewCount', 0)
-                share_count = data.get('shareCount', 0)
+                image_url = data['cover_thumbnail_urls'][0]['url']
+                video_url = data['main_mv_urls'][0]['url']
+                if ".mp4" not in video_url:
+                    continue
+                view_count = data.get('view_count', 0)
+                share_count = data.get('share_count', 0)
                 old_title = data['caption']  # 标题
 
                 video_percent = '%.4f' % (int(share_count) / int(view_count))

+ 2 - 1
video_rewriting/video_processor.py

@@ -19,6 +19,7 @@ from data_channel.douyin import DY
 from data_channel.dy_keyword import DyKeyword
 from data_channel.dy_ls import DYLS
 from data_channel.ks_feed import KSFeed
+from data_channel.ks_keyword import KsKeyword
 from data_channel.ks_ls import KSLS
 from data_channel.ks_xcx import KSXCX
 from data_channel.ks_xcx_keyword import KsXCXKeyword
@@ -496,7 +497,7 @@ class VideoProcessor:
         elif channel_id == '抖音搜索':
             return DyKeyword.get_key_word(url, task_mark, mark, channel_id, name, task)
         elif channel_id == '快手搜索':
-            return KsXCXKeyword.get_key_word(url, task_mark, mark, channel_id, name, task)
+            return KsKeyword.get_key_word(url, task_mark, mark, channel_id, name, task)
         elif channel_id == '视频号搜索':
             return SphKeyword.get_key_word(url, task_mark, mark, channel_id, name)
         elif channel_id == '快手推荐流':