lierqiang 2 rokov pred
rodič
commit
38898c3dc1
1 zmenil súbory, kde vykonal 12 pridanie a 10 odobranie
  1. 12 10
      xigua/xigua_search/xigua_search.py

+ 12 - 10
xigua/xigua_search/xigua_search.py

@@ -605,6 +605,7 @@ class Search:
                           'like_cnt': item_counter['diggCount'],
                           'share_cnt': item_counter['shareCount'],
 
+
                           'duration': data['video_duration'],
                           'publish_time_stamp': data['publish_time'],
                           'publish_time_str': time.strftime("%Y-%m-%d %H:%M:%S",
@@ -657,12 +658,12 @@ class Search:
                 return
             for video_info in search_list:
                 v_type = video_info['type']
-                item_id = video_info['data']['group_id']
                 rule_dict = cls.get_rule(log_type, crawler)
                 video_dict = {}
 
                 if v_type == 'video':
                     try:
+                        item_id = video_info['data']['group_id']
                         old_time = int(time.time()) - (3600 * 24 * rule_dict['publish_time'])
                         if video_info['data']['publish_time'] <= old_time:
                             continue
@@ -681,21 +682,22 @@ class Search:
                         video_dict['video_url'] = video_url_dict["video_url"]
                         video_dict['session'] = signature
                     except Exception as e:
-                        Common.logger(log_type, crawler).error(f'视频:{item_id},没有获取到视频详情,原因:{e}')
+                        # Common.logger(log_type, crawler).error(f'视频:{item_id},没有获取到视频详情,原因:{e}')
                         continue
                 elif v_type == 'pseries':
-                    p_url = "https://www.ixigua.com/api/videov2/pseries_more_v2?pSeriesId={}&rank=0&tailCount=30&aid=1768&msToken=wHEafKFLx0k3hihOPbhXYNsfMBxWiq2AB0K5R-34kEFixyq3ATi_DuXbL4Q47J9C2uK2zgWItMa1g2yc4FyDxM4dMijmSdwF4c4T8sSmOkoOI0wGzeEcPw==&X-Bogus=DFSzswVOzdUANG3ItaVHYr7TlqCv&_signature=_02B4Z6wo00001vB6l3QAAIDBZKzMeTihTmbwepPAANgh1Ai3JgFFo4e6anoezmBEpHfEMEYlWISGhXI-QKfev4N-2bwgXsHOuNGLnOsGqMbANIjFPh7Yj6OakQWrkbACenlv0P-arswtB6Zn45".format(
-                        item_id)
-                    p_headers = {
-                        'referer': 'https://www.ixigua.com/{}?series_flow=1&logTag=cfec9d927da968feff89'.format(
-                            item_id),
-                        'user-agent': get_random_user_agent('pc'),
-                    }
                     try:
+                        item_id = video_info['data']['group_id']
+                        p_url = "https://www.ixigua.com/api/videov2/pseries_more_v2?pSeriesId={}&rank=0&tailCount=30&aid=1768&msToken=wHEafKFLx0k3hihOPbhXYNsfMBxWiq2AB0K5R-34kEFixyq3ATi_DuXbL4Q47J9C2uK2zgWItMa1g2yc4FyDxM4dMijmSdwF4c4T8sSmOkoOI0wGzeEcPw==&X-Bogus=DFSzswVOzdUANG3ItaVHYr7TlqCv&_signature=_02B4Z6wo00001vB6l3QAAIDBZKzMeTihTmbwepPAANgh1Ai3JgFFo4e6anoezmBEpHfEMEYlWISGhXI-QKfev4N-2bwgXsHOuNGLnOsGqMbANIjFPh7Yj6OakQWrkbACenlv0P-arswtB6Zn45".format(
+                            item_id)
+                        p_headers = {
+                            'referer': 'https://www.ixigua.com/{}?series_flow=1&logTag=cfec9d927da968feff89'.format(
+                                item_id),
+                            'user-agent': get_random_user_agent('pc'),
+                        }
                         p_res = requests.request("GET", p_url, headers=p_headers,
                                                  proxies=Common.tunnel_proxies()).json()
                     except Exception as e:
-                        Common.logger(log_type, crawler).error(f'合集:{item_id},没有获取到合集详情,原因:{e}')
+                        # Common.logger(log_type, crawler).error(f'合集:{item_id},没有获取到合集详情,原因:{e}')
                         continue
                     for video in p_res['data']:
                         item_id = video['item_id']