wangkun 2 years ago
parent
commit
a0e694bc90
3 changed files with 36 additions and 2 deletions
  1. 17 0
      main/haokan_channel.py
  2. 2 2
      main/haokan_follow.py
  3. 17 0
      main/haokan_hot.py

+ 17 - 0
main/haokan_channel.py

@@ -14,6 +14,21 @@ from main.get_cookies import GetCookies
 
 
 class Channel:
+    @classmethod
+    def filter_words(cls, log_type):
+        try:
+            filter_words_sheet = Feishu.get_values_batch(log_type, 'haokan', 'nKgHzp')
+            filter_words_list = []
+            for x in filter_words_sheet:
+                for y in x:
+                    if y is None:
+                        pass
+                    else:
+                        filter_words_list.append(y)
+            return filter_words_list
+        except Exception as e:
+            Common.logger(log_type).error(f'filter_words异常:{e}')
+
     @classmethod
     def download_rule(cls, play_cnt, duration):
         if int(play_cnt) >= 10000:
@@ -217,6 +232,8 @@ class Channel:
                 Common.logger(log_type).info('无效视频\n')
             elif cls.download_rule(video_dict['play_cnt'], video_dict['duration']) is False:
                 Common.logger(log_type).info('不满足抓取规则\n')
+            elif any(word if word in video_dict['video_title'] else False for word in cls.filter_words(log_type)) is True:
+                Common.logger(log_type).info('已中过滤词库\n')
             elif video_dict['video_id'] in [x for y in Feishu.get_values_batch(log_type, 'haokan', '5pWipX') for x in y]:
                 Common.logger(log_type).info('视频已下载\n')
             elif video_dict['video_id'] in [x for y in Feishu.get_values_batch(log_type, 'haokan', '7f05d8') for x in y]:

+ 2 - 2
main/haokan_follow.py

@@ -50,8 +50,8 @@ class Follow:
 
     @classmethod
     def follow_download_rule(cls, duration, width, height):
-        if int(duration) >= 60:
-            if int(width) >= 720 or int(height) >= 720:
+        if int(duration) >= 40:
+            if int(width) >= 0 or int(height) >= 0:
                 return True
             else:
                 return False

+ 17 - 0
main/haokan_hot.py

@@ -17,6 +17,21 @@ class Hot:
 
     page = 0
 
+    @classmethod
+    def filter_words(cls, log_type):
+        try:
+            filter_words_sheet = Feishu.get_values_batch(log_type, 'haokan', 'nKgHzp')
+            filter_words_list = []
+            for x in filter_words_sheet:
+                for y in x:
+                    if y is None:
+                        pass
+                    else:
+                        filter_words_list.append(y)
+            return filter_words_list
+        except Exception as e:
+            Common.logger(log_type).error(f'filter_words异常:{e}')
+
     @classmethod
     def get_hot_feeds(cls, log_type, our_id, env):
         try:
@@ -176,6 +191,8 @@ class Hot:
     def download_publish(cls, log_type, video_dict, our_id, env):
         if video_dict['video_title'] == 0 or video_dict['video_url'] == 0:
             Common.logger(log_type).info('无效视频\n')
+        elif any(word if word in video_dict['video_title'] else False for word in cls.filter_words(log_type)) is True:
+            Common.logger(log_type).info('已中过滤词库\n')
         elif video_dict['video_id'] in [x for y in Feishu.get_values_batch(log_type, 'haokan', '5pWipX') for x in y]:
             Common.logger(log_type).info('视频已下载\n')
         elif video_dict['video_id'] in [x for y in Feishu.get_values_batch(log_type, 'haokan', '7f05d8') for x in y]: