Browse Source

修改公众号去重规则

罗俊辉 1 year ago
parent
commit
4658917b42
1 changed files with 4 additions and 3 deletions
  1. 4 3
      gongzhonghao/gongzhonghao_author/gongzhonghao_author.py

+ 4 - 3
gongzhonghao/gongzhonghao_author/gongzhonghao_author.py

@@ -427,7 +427,7 @@ class GongzhonghaoAuthor:
                                 message="标题已中过滤词\n"
                             )
                         # 已下载判断
-                        elif cls.repeat_video(log_type, crawler, video_dict['video_id'], env) != 0:
+                        elif cls.repeat_video(log_type, crawler, video_dict['video_id'], video_dict['video_title'], env) != 0:
                             Common.logger(log_type, crawler).info("视频已下载\n")
                             Common.logging(log_type, crawler, env, "视频已下载\n")
                             AliyunLogger.logging(
@@ -479,9 +479,10 @@ class GongzhonghaoAuthor:
                 time.sleep(60)
 
     @classmethod
-    def repeat_video(cls, log_type, crawler, video_id, env):
+    def repeat_video(cls, log_type, crawler, video_id, video_title, env):
         # sql = f""" select * from crawler_video where platform="公众号" and out_video_id="{video_id}"; """
-        sql = f""" select * from crawler_video where platform in ("{crawler}","{cls.platform}") and out_video_id="{video_id}"; """
+        # sql = f""" select * from crawler_video where platform in ("{crawler}","{cls.platform}") and out_video_id="{video_id}" ; """
+        sql = f"""select * from crawler_video where platform = "{crawler}" and (out_video_id="{video_id}" or video_title="{video_title}") ;"""
         repeat_video = MysqlHelper.get_values(log_type, crawler, sql, env)
         return len(repeat_video)