Przeglądaj źródła

rank---微信体系内只要有返回则选择微信体系内视频

罗俊辉 1 rok temu
rodzic
commit
774f26f7dc
1 zmienionych plików z 29 dodań i 17 usunięć
  1. 29 17
      applications/search.py

+ 29 - 17
applications/search.py

@@ -89,12 +89,16 @@ def return_video(video_path, title, trace_id):
         else:
             obj_list = title_result['data']['data']
             for obj in obj_list:
-                title = obj['items'][0]['title'].replace('<em class=\"highlight\">', '').replace('</em>',
+                try:
+                    title = obj['items'][0]['title'].replace('<em class=\"highlight\">', '').replace('</em>',
                                                                                                  '').replace("#",
-                                                                                                             "")
-                if sensitive_flag(title):
-                    return obj
-                else:
+                                                                                                        "")
+                    if sensitive_flag(title):
+                        return obj
+                    else:
+                        continue
+                except Exception as e:
+                    print(e)
                     continue
 
         # search_keys
@@ -108,12 +112,16 @@ def return_video(video_path, title, trace_id):
         else:
             obj_list = search_keys_result['data']['data']
             for obj in obj_list:
-                title = obj['items'][0]['title'].replace('<em class=\"highlight\">', '').replace('</em>',
-                                                                                                 '').replace("#",
-                                                                                                             "")
-                if sensitive_flag(title):
-                    return obj
-                else:
+                try:
+                    title = obj['items'][0]['title'].replace('<em class=\"highlight\">', '').replace('</em>',
+                                                                                                     '').replace("#",
+                                                                                                                 "")
+                    if sensitive_flag(title):
+                        return obj
+                    else:
+                        continue
+                except Exception as e:
+                    print(e)
                     continue
 
         # theme
@@ -127,12 +135,16 @@ def return_video(video_path, title, trace_id):
         else:
             obj_list = theme_result['data']['data']
             for obj in obj_list:
-                title = obj['items'][0]['title'].replace('<em class=\"highlight\">', '').replace('</em>',
-                                                                                                 '').replace("#",
-                                                                                                             "")
-                if sensitive_flag(title):
-                    return obj
-                else:
+                try:
+                    title = obj['items'][0]['title'].replace('<em class=\"highlight\">', '').replace('</em>',
+                                                                                                     '').replace("#",
+                                                                                                                 "")
+                    if sensitive_flag(title):
+                        return obj
+                    else:
+                        continue
+                except Exception as e:
+                    print(e)
                     continue
         return None
     else: