浏览代码

2024-05-13
多平台搜索上线(微信, 百度, 西瓜)
弃用 search_keys, theme
搜索结果过pq敏感词策略

罗俊辉 1 年之前
父节点
当前提交
5cf5a3137f
共有 3 个文件被更改,包括 21 次插入16 次删除
  1. 16 15
      applications/schedule/search_schedule.py
  2. 2 0
      applications/search/hksp_search.py
  3. 3 1
      applications/search/xigua_search.py

+ 16 - 15
applications/schedule/search_schedule.py

@@ -79,21 +79,22 @@ def search_videos(video_path, title, trace_id, gh_id):
     :return:
     :return:
     """
     """
     recall_obj = recall_search_video(video_path, title, trace_id)
     recall_obj = recall_search_video(video_path, title, trace_id)
-    platform = recall_obj["platform"]
-    recall_video = recall_obj["result"]
-    if recall_video:
-        logging(
-            code="7002",
-            info="视频搜索成功, 搜索平台为--{}".format(platform),
-            trace_id=trace_id,
-            data=recall_video
-        )
-        video_mq_sender(
-            video_obj=recall_video,
-            user=gh_id_dict.get(gh_id),
-            trace_id=trace_id,
-            platform=platform
-        )
+    if recall_obj:
+        platform = recall_obj["platform"]
+        recall_video = recall_obj["result"]
+        if recall_video:
+            logging(
+                code="7002",
+                info="视频搜索成功, 搜索平台为--{}".format(platform),
+                trace_id=trace_id,
+                data=recall_video
+            )
+            video_mq_sender(
+                video_obj=recall_video,
+                user=gh_id_dict.get(gh_id),
+                trace_id=trace_id,
+                platform=platform
+            )
     else:
     else:
         logging(
         logging(
             code="7003",
             code="7003",

+ 2 - 0
applications/search/hksp_search.py

@@ -102,6 +102,8 @@ def hksp_search(key):
     }
     }
     # 发送GET请求
     # 发送GET请求
     response = requests.get(url, headers=headers, params=params).json()
     response = requests.get(url, headers=headers, params=params).json()
+    print("baidu search")
+    print(response)
     try:
     try:
         data_list = response['data']['list']
         data_list = response['data']['list']
         L = []
         L = []

+ 3 - 1
applications/search/xigua_search.py

@@ -212,11 +212,13 @@ def xigua_search(keyword):
                 video_d = XiGuaFunctions().get_video_info(doc_id)
                 video_d = XiGuaFunctions().get_video_info(doc_id)
                 video_title = video_d['video_title']
                 video_title = video_d['video_title']
                 if sensitive_flag(sensitive_words, video_title) and int(video_d['duration']) <= 300:
                 if sensitive_flag(sensitive_words, video_title) and int(video_d['duration']) <= 300:
+                    print("西瓜视频信息")
+                    print(video_d)
                     L.append(video_d)
                     L.append(video_d)
                 else:
                 else:
                     continue
                     continue
             except Exception as e:
             except Exception as e:
-                print(e)
+                # print(e)
                 continue
                 continue
         return L
         return L
     else:
     else: