|
@@ -548,6 +548,27 @@ class XiguaRecommend:
|
|
except Exception as e:
|
|
except Exception as e:
|
|
Common.logger(log_type, crawler).error(f'get_video_url:{e}\n')
|
|
Common.logger(log_type, crawler).error(f'get_video_url:{e}\n')
|
|
|
|
|
|
|
|
+ # 过滤词库
|
|
|
|
+ @classmethod
|
|
|
|
+ def filter_words(cls, log_type, crawler):
|
|
|
|
+ try:
|
|
|
|
+ while True:
|
|
|
|
+ filter_words_sheet = Feishu.get_values_batch(log_type, crawler, 'KGB4Hc')
|
|
|
|
+ if filter_words_sheet is None:
|
|
|
|
+ Common.logger(log_type, crawler).warning(
|
|
|
|
+ f"filter_words_sheet:{filter_words_sheet} 10秒钟后重试")
|
|
|
|
+ continue
|
|
|
|
+ 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, crawler).error(f'filter_words异常:{e}\n')
|
|
|
|
+
|
|
@classmethod
|
|
@classmethod
|
|
def get_videolist(cls, log_type, crawler, env):
|
|
def get_videolist(cls, log_type, crawler, env):
|
|
while True:
|
|
while True:
|
|
@@ -687,6 +708,9 @@ class XiguaRecommend:
|
|
def download_publish(cls, log_type, crawler, video_dict):
|
|
def download_publish(cls, log_type, crawler, video_dict):
|
|
if video_dict['video_id'] in [y for x in Feishu.get_values_batch(log_type, crawler, "1iKGF1") for y in x]:
|
|
if video_dict['video_id'] in [y for x in Feishu.get_values_batch(log_type, crawler, "1iKGF1") for y in x]:
|
|
Common.logger(log_type, crawler).info("视频已存在\n")
|
|
Common.logger(log_type, crawler).info("视频已存在\n")
|
|
|
|
+ elif any(word if word in video_dict['video_title'] else False for word in
|
|
|
|
+ cls.filter_words(log_type, crawler)) is True:
|
|
|
|
+ Common.logger(log_type, crawler).info('标题已中过滤词\n')
|
|
else:
|
|
else:
|
|
Feishu.insert_columns(log_type, crawler, "1iKGF1", "ROWS", 1, 2)
|
|
Feishu.insert_columns(log_type, crawler, "1iKGF1", "ROWS", 1, 2)
|
|
values = [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
|
|
values = [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
|
|
@@ -719,4 +743,5 @@ if __name__ == "__main__":
|
|
# XiguaRecommend.get_signature("recommend", "xigua", "dev")
|
|
# XiguaRecommend.get_signature("recommend", "xigua", "dev")
|
|
XiguaRecommend.get_videolist("recommend", "xigua", "dev")
|
|
XiguaRecommend.get_videolist("recommend", "xigua", "dev")
|
|
# print(XiguaRecommend.get_video_url("recommend", "xigua", "7218171653242094139"))
|
|
# print(XiguaRecommend.get_video_url("recommend", "xigua", "7218171653242094139"))
|
|
|
|
+ # print(XiguaRecommend.filter_words("recommend", "xigua"))
|
|
pass
|
|
pass
|