Преглед изворни кода

修改排序算法-返回重复视频

罗俊辉 пре 11 месеци
родитељ
комит
5dd60a3fcd
2 измењених фајлова са 46 додато и 10 уклоњено
  1. 45 9
      applications/pipeline.py
  2. 1 1
      routes/AccountArticleRank.py

+ 45 - 9
applications/pipeline.py

@@ -50,30 +50,66 @@ class LongArticlesPipeline(object):
         )
         return response.json()['is_sensitive']
 
+    @classmethod
+    def article_bad(cls, title, account_nickname):
+        """
+        判断该文章是否为劣质文章
+        :param title:
+        :param account_nickname:
+        :return:
+        """
+        url = "http://192.168.100.31:8176/bad/is_bad"
+        headers = {
+            "accept": "application/json",
+            "Content-Type": "application/json"
+        }
+        body = {
+            "account_nickname": account_nickname,
+            "title": title
+        }
+        response = requests.request(
+            "POST",
+            url=url,
+            headers=headers,
+            json=body
+        )
+        return response.json()['is_bad']
+
     @classmethod
     def deal(cls, article_obj):
         """
         :param article_obj:
         :return:
         """
-        history_exists_flag = cls.history_exists(
+        article_bad_flag = cls.article_bad(
             title=article_obj['title'],
-            account_nickname=article_obj['crawlerAccountName'],
-            plan_name=article_obj['producePlanName']
+            account_nickname=article_obj['crawlerAccountName']
         )
-        if history_exists_flag:
+        if article_bad_flag:
             response = {
-                "fileterReason": "历史已发布文章",
+                "filterReason": "历史表现差的文章",
                 "status": True
             }
             return response
         else:
-            safe_flag = cls.article_safe(title=article_obj['title'])
-            if safe_flag:
+            history_exists_flag = cls.history_exists(
+                title=article_obj['title'],
+                account_nickname=article_obj['crawlerAccountName'],
+                plan_name=article_obj['producePlanName']
+            )
+            if history_exists_flag:
                 response = {
-                    "fileterReason": "安全违规",
+                    "filterReason": "历史已发布文章",
                     "status": True
                 }
                 return response
             else:
-                return False
+                safe_flag = cls.article_safe(title=article_obj['title'])
+                if safe_flag:
+                    response = {
+                        "filterReason": "安全违规",
+                        "status": True
+                    }
+                    return response
+                else:
+                    return False

+ 1 - 1
routes/AccountArticleRank.py

@@ -65,7 +65,7 @@ class AccountArticleRank(object):
         for item in self.params['publishArticleList']:
             flag = self.pipeline.deal(item)
             if flag:
-                item['filterReason'] = flag['fileterReason']
+                item['filterReason'] = flag['filterReason']
                 self.filter_list.append(item)
             else:
                 self.publishArticleList.append(item)