wangkun 2 gadi atpakaļ
vecāks
revīzija
bb31a94494
2 mainītis faili ar 324 papildinājumiem un 323 dzēšanām
  1. 321 321
      main/xigua_follow.py
  2. 3 2
      main/xigua_publish.py

+ 321 - 321
main/xigua_follow.py

@@ -88,71 +88,122 @@ class Follow:
     # 获取视频详情
     @classmethod
     def get_video_url(cls, log_type, gid):
-        try:
-            url = 'https://www.ixigua.com/api/mixVideo/information?'
-            headers = {
-                "accept-encoding": "gzip, deflate",
-                "accept-language": "zh-CN,zh-Hans;q=0.9",
-                "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
-                              "AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15",
-                "referer": "https://www.ixigua.com/7102614741050196520?logTag=0531c88ac04f38ab2c62",
-            }
-            params = {
-                'mixId': gid,
-                'msToken': 'IlG0wd0Pylyw9ghcYiB2YseUmTwrsrqqhXrbIcsSaTcLTJyVlbYJzk20zw3UO-CfrfC'
-                           'NVVIOBNjIl7vfBoxnVUwO9ZyzAI3umSKsT5-pef_RRfQCJwmA',
-                'X-Bogus': 'DFSzswVupYTANCJOSBk0P53WxM-r',
-                '_signature': '_02B4Z6wo0000119LvEwAAIDCuktNZ0y5wkdfS7jAALThuOR8D9yWNZ.EmWHKV0WSn6Px'
-                              'fPsH9-BldyxVje0f49ryXgmn7Tzk-swEHNb15TiGqa6YF.cX0jW8Eds1TtJOIZyfc9s5emH7gdWN94',
-            }
-            cookies = {
-                'ixigua-a-s': '1',
-                'msToken': 'IlG0wd0Pylyw9ghcYiB2YseUmTwrsrqqhXrbIcsSaTcLTJyVlbYJzk20zw3UO-CfrfCNVVIOB'
-                           'NjIl7vfBoxnVUwO9ZyzAI3umSKsT5-pef_RRfQCJwmA',
-                'ttwid': '1%7C_yXQeHWwLZgCsgHClOwTCdYSOt_MjdOkgnPIkpi-Sr8%7C1661241238%7Cf57d0c5ef3f1d7'
-                         '6e049fccdca1ac54887c34d1f8731c8e51a49780ff0ceab9f8',
-                'tt_scid': 'QZ4l8KXDG0YAEaMCSbADdcybdKbUfG4BC6S4OBv9lpRS5VyqYLX2bIR8CTeZeGHR9ee3',
-                'MONITOR_WEB_ID': '0a49204a-7af5-4e96-95f0-f4bafb7450ad',
-                '__ac_nonce': '06304878000964fdad287',
-                '__ac_signature': '_02B4Z6wo00f017Rcr3AAAIDCUVxeW1tOKEu0fKvAAI4cvoYzV-wBhq7B6D8k0no7lb'
-                                  'FlvYoinmtK6UXjRIYPXnahUlFTvmWVtb77jsMkKAXzAEsLE56m36RlvL7ky.M3Xn52r9t1IEb7IR3ke8',
-                'ttcid': 'e56fabf6e85d4adf9e4d91902496a0e882',
-                '_tea_utm_cache_1300': 'undefined',
-                'support_avif': 'false',
-                'support_webp': 'false',
-                'xiguavideopcwebid': '7134967546256016900',
-                'xiguavideopcwebid.sig': 'xxRww5R1VEMJN_dQepHorEu_eAc',
-            }
-            urllib3.disable_warnings()
-            response = requests.get(url=url, headers=headers, params=params, cookies=cookies, proxies=proxies,
-                                    verify=False)
-            if 'data' not in response.json() or response.json()['data'] == '':
-                Common.logger(log_type).warning('get_video_info: response: {}', response)
-            else:
-                video_info = response.json()['data']['gidInformation']['packerData']['video']
-
-                video_url = ''
-                audio_url = ''
-                video_width = ''
-                video_height = ''
-
-                # video_url
-                if 'videoResource' not in video_info:
-                    video_url = 0
-                    audio_url = 0
-                    video_width = 0
-                    video_height = 0
-                elif 'dash' in video_info['videoResource'] \
-                        and 'dynamic_video' in video_info['videoResource']['dash'] \
-                        and 'dynamic_video_list' in video_info['videoResource']['dash']['dynamic_video']:
-                    video_url = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
-                        'main_url']
-                    audio_url = video_info['videoResource']['dash']['dynamic_video']['dynamic_audio_list'][-1][
-                        'main_url']
-
-                    # Common.logger(log_type).info(f'main_video_url:{video_url}')
-                    # Common.logger(log_type).info(f'main_audio_url:{audio_url}\n')
-
+        # try:
+        url = 'https://www.ixigua.com/api/mixVideo/information?'
+        headers = {
+            "accept-encoding": "gzip, deflate",
+            "accept-language": "zh-CN,zh-Hans;q=0.9",
+            "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
+                          "AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15",
+            "referer": "https://www.ixigua.com/7102614741050196520?logTag=0531c88ac04f38ab2c62",
+        }
+        params = {
+            'mixId': gid,
+            'msToken': 'IlG0wd0Pylyw9ghcYiB2YseUmTwrsrqqhXrbIcsSaTcLTJyVlbYJzk20zw3UO-CfrfC'
+                       'NVVIOBNjIl7vfBoxnVUwO9ZyzAI3umSKsT5-pef_RRfQCJwmA',
+            'X-Bogus': 'DFSzswVupYTANCJOSBk0P53WxM-r',
+            '_signature': '_02B4Z6wo0000119LvEwAAIDCuktNZ0y5wkdfS7jAALThuOR8D9yWNZ.EmWHKV0WSn6Px'
+                          'fPsH9-BldyxVje0f49ryXgmn7Tzk-swEHNb15TiGqa6YF.cX0jW8Eds1TtJOIZyfc9s5emH7gdWN94',
+        }
+        cookies = {
+            'ixigua-a-s': '1',
+            'msToken': 'IlG0wd0Pylyw9ghcYiB2YseUmTwrsrqqhXrbIcsSaTcLTJyVlbYJzk20zw3UO-CfrfCNVVIOB'
+                       'NjIl7vfBoxnVUwO9ZyzAI3umSKsT5-pef_RRfQCJwmA',
+            'ttwid': '1%7C_yXQeHWwLZgCsgHClOwTCdYSOt_MjdOkgnPIkpi-Sr8%7C1661241238%7Cf57d0c5ef3f1d7'
+                     '6e049fccdca1ac54887c34d1f8731c8e51a49780ff0ceab9f8',
+            'tt_scid': 'QZ4l8KXDG0YAEaMCSbADdcybdKbUfG4BC6S4OBv9lpRS5VyqYLX2bIR8CTeZeGHR9ee3',
+            'MONITOR_WEB_ID': '0a49204a-7af5-4e96-95f0-f4bafb7450ad',
+            '__ac_nonce': '06304878000964fdad287',
+            '__ac_signature': '_02B4Z6wo00f017Rcr3AAAIDCUVxeW1tOKEu0fKvAAI4cvoYzV-wBhq7B6D8k0no7lb'
+                              'FlvYoinmtK6UXjRIYPXnahUlFTvmWVtb77jsMkKAXzAEsLE56m36RlvL7ky.M3Xn52r9t1IEb7IR3ke8',
+            'ttcid': 'e56fabf6e85d4adf9e4d91902496a0e882',
+            '_tea_utm_cache_1300': 'undefined',
+            'support_avif': 'false',
+            'support_webp': 'false',
+            'xiguavideopcwebid': '7134967546256016900',
+            'xiguavideopcwebid.sig': 'xxRww5R1VEMJN_dQepHorEu_eAc',
+        }
+        urllib3.disable_warnings()
+        response = requests.get(url=url, headers=headers, params=params, cookies=cookies, proxies=proxies,
+                                verify=False)
+        if 'data' not in response.json() or response.json()['data'] == '':
+            Common.logger(log_type).warning('get_video_info: response: {}', response)
+        else:
+            video_info = response.json()['data']['gidInformation']['packerData']['video']
+
+            video_url = ''
+            audio_url = ''
+            video_width = ''
+            video_height = ''
+
+            # video_url
+            if 'videoResource' not in video_info:
+                video_url = 0
+                audio_url = 0
+                video_width = 0
+                video_height = 0
+            elif 'dash' in video_info['videoResource'] \
+                    and 'dynamic_video' in video_info['videoResource']['dash'] \
+                    and 'dynamic_video_list' in video_info['videoResource']['dash']['dynamic_video']:
+                video_url = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
+                    'main_url']
+                audio_url = video_info['videoResource']['dash']['dynamic_video']['dynamic_audio_list'][-1][
+                    'main_url']
+
+                # Common.logger(log_type).info(f'main_video_url:{video_url}')
+                # Common.logger(log_type).info(f'main_audio_url:{audio_url}\n')
+
+                if len(video_url) % 3 == 1:
+                    video_url += '=='
+                elif len(video_url) % 3 == 2:
+                    video_url += '='
+                elif len(audio_url) % 3 == 1:
+                    audio_url += '=='
+                elif len(audio_url) % 3 == 2:
+                    audio_url += '='
+
+                # Common.logger(log_type).info(f'%_video_url:{video_url}')
+                # Common.logger(log_type).info(f'%_audio_url:{audio_url}\n')
+
+                video_url = base64.b64decode(video_url).decode('utf8')
+                audio_url = base64.b64decode(audio_url).decode('utf8')
+
+                # Common.logger(log_type).info(f'base64_video_url:{video_url}')
+                # Common.logger(log_type).info(f'base64_audio_url:{audio_url}\n')
+
+                video_width = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
+                    'vwidth']
+                video_height = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
+                    'vheight']
+
+            elif 'dash_120fps' in video_info['videoResource'] \
+                    and 'dynamic_video' in video_info['videoResource']['dash_120fps'] \
+                    and 'dynamic_video_list' in video_info['videoResource']['dash_120fps']['dynamic_video']:
+                video_url = video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list'][-1][
+                    'main_url']
+                audio_url = video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_audio_list'][-1][
+                    'main_url']
+                if len(video_url) % 3 == 1:
+                    video_url += '=='
+                elif len(video_url) % 3 == 2:
+                    video_url += '='
+                elif len(audio_url) % 3 == 1:
+                    audio_url += '=='
+                elif len(audio_url) % 3 == 2:
+                    audio_url += '='
+                video_url = base64.b64decode(video_url).decode('utf8')
+                audio_url = base64.b64decode(audio_url).decode('utf8')
+                video_width = video_info['videoResource']['dash_120fps']['dynamic_video'][
+                    'dynamic_video_list'][-1]['vwidth']
+                video_height = video_info['videoResource']['dash_120fps']['dynamic_video'][
+                    'dynamic_video_list'][-1]['vheight']
+
+            elif 'normal' in video_info['videoResource']:
+                video_list = video_info['videoResource']['normal']['video_list']
+                if 'video_4' in video_list.keys():
+                    # Common.logger(log_type).info('{}', video_list['video_4'])
+                    video_url = video_list['video_4']['main_url']
+                    audio_url = video_list['video_4']['main_url']
                     if len(video_url) % 3 == 1:
                         video_url += '=='
                     elif len(video_url) % 3 == 2:
@@ -161,28 +212,14 @@ class Follow:
                         audio_url += '=='
                     elif len(audio_url) % 3 == 2:
                         audio_url += '='
-
-                    # Common.logger(log_type).info(f'%_video_url:{video_url}')
-                    # Common.logger(log_type).info(f'%_audio_url:{audio_url}\n')
-
                     video_url = base64.b64decode(video_url).decode('utf8')
                     audio_url = base64.b64decode(audio_url).decode('utf8')
-
-                    # Common.logger(log_type).info(f'base64_video_url:{video_url}')
-                    # Common.logger(log_type).info(f'base64_audio_url:{audio_url}\n')
-
-                    video_width = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
-                        'vwidth']
-                    video_height = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
-                        'vheight']
-
-                elif 'dash_120fps' in video_info['videoResource'] \
-                        and 'dynamic_video' in video_info['videoResource']['dash_120fps'] \
-                        and 'dynamic_video_list' in video_info['videoResource']['dash_120fps']['dynamic_video']:
-                    video_url = video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list'][-1][
-                        'main_url']
-                    audio_url = video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_audio_list'][-1][
-                        'main_url']
+                    video_width = video_list['video_4']['vwidth']
+                    video_height = video_list['video_4']['vheight']
+                elif 'video_3' in video_list.keys():
+                    # Common.logger(log_type).info('{}', video_list['video_3'])
+                    video_url = video_list['video_3']['main_url']
+                    audio_url = video_list['video_3']['main_url']
                     if len(video_url) % 3 == 1:
                         video_url += '=='
                     elif len(video_url) % 3 == 2:
@@ -193,239 +230,202 @@ class Follow:
                         audio_url += '='
                     video_url = base64.b64decode(video_url).decode('utf8')
                     audio_url = base64.b64decode(audio_url).decode('utf8')
-                    video_width = video_info['videoResource']['dash_120fps']['dynamic_video'][
-                        'dynamic_video_list'][-1]['vwidth']
-                    video_height = video_info['videoResource']['dash_120fps']['dynamic_video'][
-                        'dynamic_video_list'][-1]['vheight']
-
-                elif 'normal' in video_info['videoResource']:
-                    video_list = video_info['videoResource']['normal']['video_list']
-                    if 'video_4' in video_list.keys():
-                        # Common.logger(log_type).info('{}', video_list['video_4'])
-                        video_url = video_list['video_4']['main_url']
-                        audio_url = video_list['video_4']['main_url']
-                        if len(video_url) % 3 == 1:
-                            video_url += '=='
-                        elif len(video_url) % 3 == 2:
-                            video_url += '='
-                        elif len(audio_url) % 3 == 1:
-                            audio_url += '=='
-                        elif len(audio_url) % 3 == 2:
-                            audio_url += '='
-                        video_url = base64.b64decode(video_url).decode('utf8')
-                        audio_url = base64.b64decode(audio_url).decode('utf8')
-                        video_width = video_list['video_4']['vwidth']
-                        video_height = video_list['video_4']['vheight']
-                    elif 'video_3' in video_list.keys():
-                        # Common.logger(log_type).info('{}', video_list['video_3'])
-                        video_url = video_list['video_3']['main_url']
-                        audio_url = video_list['video_3']['main_url']
-                        if len(video_url) % 3 == 1:
-                            video_url += '=='
-                        elif len(video_url) % 3 == 2:
-                            video_url += '='
-                        elif len(audio_url) % 3 == 1:
-                            audio_url += '=='
-                        elif len(audio_url) % 3 == 2:
-                            audio_url += '='
-                        video_url = base64.b64decode(video_url).decode('utf8')
-                        audio_url = base64.b64decode(audio_url).decode('utf8')
-                        video_width = video_list['video_3']['vwidth']
-                        video_height = video_list['video_3']['vheight']
-                    elif 'video_2' in video_list.keys():
-                        # Common.logger(log_type).info('{}', video_list['video_2'])
-                        video_url = video_list['video_2']['main_url']
-                        audio_url = video_list['video_2']['main_url']
-                        if len(video_url) % 3 == 1:
-                            video_url += '=='
-                        elif len(video_url) % 3 == 2:
-                            video_url += '='
-                        elif len(audio_url) % 3 == 1:
-                            audio_url += '=='
-                        elif len(audio_url) % 3 == 2:
-                            audio_url += '='
-                        video_url = base64.b64decode(video_url).decode('utf8')
-                        audio_url = base64.b64decode(audio_url).decode('utf8')
-                        video_width = video_list['video_2']['vwidth']
-                        video_height = video_list['video_2']['vheight']
-                    elif 'video_1' in video_list.keys():
-                        # Common.logger(log_type).info('{}', video_list['video_1'])
-                        video_url = video_list['video_1']['main_url']
-                        audio_url = video_list['video_1']['main_url']
-                        if len(video_url) % 3 == 1:
-                            video_url += '=='
-                        elif len(video_url) % 3 == 2:
-                            video_url += '='
-                        elif len(audio_url) % 3 == 1:
-                            audio_url += '=='
-                        elif len(audio_url) % 3 == 2:
-                            audio_url += '='
-                        video_url = base64.b64decode(video_url).decode('utf8')
-                        audio_url = base64.b64decode(audio_url).decode('utf8')
-                        video_width = video_list['video_1']['vwidth']
-                        video_height = video_list['video_1']['vheight']
-                    else:
-                        video_url = 0
-                        audio_url = 0
-                        video_width = 0
-                        video_height = 0
+                    video_width = video_list['video_3']['vwidth']
+                    video_height = video_list['video_3']['vheight']
+                elif 'video_2' in video_list.keys():
+                    # Common.logger(log_type).info('{}', video_list['video_2'])
+                    video_url = video_list['video_2']['main_url']
+                    audio_url = video_list['video_2']['main_url']
+                    if len(video_url) % 3 == 1:
+                        video_url += '=='
+                    elif len(video_url) % 3 == 2:
+                        video_url += '='
+                    elif len(audio_url) % 3 == 1:
+                        audio_url += '=='
+                    elif len(audio_url) % 3 == 2:
+                        audio_url += '='
+                    video_url = base64.b64decode(video_url).decode('utf8')
+                    audio_url = base64.b64decode(audio_url).decode('utf8')
+                    video_width = video_list['video_2']['vwidth']
+                    video_height = video_list['video_2']['vheight']
+                elif 'video_1' in video_list.keys():
+                    # Common.logger(log_type).info('{}', video_list['video_1'])
+                    video_url = video_list['video_1']['main_url']
+                    audio_url = video_list['video_1']['main_url']
+                    if len(video_url) % 3 == 1:
+                        video_url += '=='
+                    elif len(video_url) % 3 == 2:
+                        video_url += '='
+                    elif len(audio_url) % 3 == 1:
+                        audio_url += '=='
+                    elif len(audio_url) % 3 == 2:
+                        audio_url += '='
+                    video_url = base64.b64decode(video_url).decode('utf8')
+                    audio_url = base64.b64decode(audio_url).decode('utf8')
+                    video_width = video_list['video_1']['vwidth']
+                    video_height = video_list['video_1']['vheight']
+                else:
+                    video_url = 0
+                    audio_url = 0
+                    video_width = 0
+                    video_height = 0
 
-                return video_url, audio_url, video_width, video_height
+            return video_url, audio_url, video_width, video_height
 
-        except Exception as e:
-            Common.logger(log_type).error(f'get_video_info异常:{e}\n')
+        # except Exception as e:
+        #     Common.logger(log_type).error(f'get_video_info异常:{e}\n')
 
     @classmethod
     def get_feeds(cls, log_type, outid):
-        try:
-            url = "https://www.ixigua.com/api/videov2/author/new_video_list?"
-            headers = {
-                'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
-                'accept': 'application/json, text/plain, */*',
-                'sec-ch-ua-mobile': '?0',
-                'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko)'
-                              ' Chrome/103.0.0.0 Safari/537.36',
-                'sec-ch-ua-platform': '"macOS"',
-                'sec-fetch-site': 'same-origin',
-                'sec-fetch-mode': 'cors',
-                'sec-fetch-dest': 'document',
-                'referer': 'https://www.ixigua.com/home/' + str(outid),
-                'accept-encoding': 'gzip, deflate',
-                'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
-            }
-            params = {
-                'to_user_id': str(outid),
-                'offset': str(cls.offset),
-                'limit': '30',
-                'maxBehotTime': '0',
-                'order': 'new',
-                'isHome': '0',
-                'msToken': '2ZHINOMBPK-qlCKApv37xVCBKkXyPli8mTYNlTSXvr17eZ0Ea8B__Otimkx6q_'
-                           'enDc9m8Kgzi3Re7wpLIMSSE9dofTYdqQgvB7mHQbx_AMnVnf5lsByU',
-                'X-Bogus': 'DFSzswVuVvTANe2BSBBMCR/F6qyc',
-                '_signature': Feishu.get_values_batch(log_type, 'xigua', '6tZHhs')[1][1],
-            }
-            cookies = {
-                '__ac_signature': '_02B4Z6wo00f017vzS8QAAIDCwz2gwwDpX9-7009AAI4Bc4',
-                'MONITOR_WEB_ID': 'fd4244aa-2003-4e19-a2a4-715c19310a56',
-                'ixigua-a-s': '1',
-                'support_webp': 'true',
-                'support_avif': 'true',
-                '_tea_utm_cache_1300': 'undefined',
-                'ttcid': '16a3b6b9b80b4a87ae258f5f3f101e6310',
-                'msToken': 'G8pL2oH-9Zl1hrLZPyOMSceMaII3ejKda2o-tgO1heYrj7b_fgm9vGlvwyLOA2H8oUShZgAYfxEvIuktT'
-                           '7OuxBuy85N-ousFfqxuAIrfruMEFZUTYp2z',
-                'tt_scid': 'a0zhISPImN-dVMMdbeb1Kzhl1x4oJS5Yr81FzH6qYk3jDtj1d2E5gsywN4rwna8ib398',
-                'ttwid': '1%7CvorN1HQjbSgBViRkEoZYEbqP_sQVoQqaUqGcFA-bzpA%7C1661324763%7Ce040213e1107973ebb0d'
-                         'b64f0e77cfb027375f1fb5854bb40588d692d025af1f',
-            }
-            urllib3.disable_warnings()
-            response = requests.get(url=url, headers=headers, params=params,
-                                    cookies=cookies, proxies=proxies, verify=False)
-            cls.offset += 30
-            if 'data' not in response.text or response.json()['data'] == '' or response.json()['code'] != 200:
-                Common.logger(log_type).info('get_follow_feeds: response:{}', response.text)
-            else:
-                feeds = response.json()['data']['videoList']
-                return feeds
-        except Exception as e:
-            Common.logger(log_type).error(f'get_feeds异常:{e}\n')
+        # try:
+        url = "https://www.ixigua.com/api/videov2/author/new_video_list?"
+        headers = {
+            'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
+            'accept': 'application/json, text/plain, */*',
+            'sec-ch-ua-mobile': '?0',
+            'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko)'
+                          ' Chrome/103.0.0.0 Safari/537.36',
+            'sec-ch-ua-platform': '"macOS"',
+            'sec-fetch-site': 'same-origin',
+            'sec-fetch-mode': 'cors',
+            'sec-fetch-dest': 'document',
+            'referer': 'https://www.ixigua.com/home/' + str(outid),
+            'accept-encoding': 'gzip, deflate',
+            'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
+        }
+        params = {
+            'to_user_id': str(outid),
+            'offset': str(cls.offset),
+            'limit': '30',
+            'maxBehotTime': '0',
+            'order': 'new',
+            'isHome': '0',
+            'msToken': '2ZHINOMBPK-qlCKApv37xVCBKkXyPli8mTYNlTSXvr17eZ0Ea8B__Otimkx6q_'
+                       'enDc9m8Kgzi3Re7wpLIMSSE9dofTYdqQgvB7mHQbx_AMnVnf5lsByU',
+            'X-Bogus': 'DFSzswVuVvTANe2BSBBMCR/F6qyc',
+            '_signature': Feishu.get_values_batch(log_type, 'xigua', '6tZHhs')[1][1],
+        }
+        cookies = {
+            '__ac_signature': '_02B4Z6wo00f017vzS8QAAIDCwz2gwwDpX9-7009AAI4Bc4',
+            'MONITOR_WEB_ID': 'fd4244aa-2003-4e19-a2a4-715c19310a56',
+            'ixigua-a-s': '1',
+            'support_webp': 'true',
+            'support_avif': 'true',
+            '_tea_utm_cache_1300': 'undefined',
+            'ttcid': '16a3b6b9b80b4a87ae258f5f3f101e6310',
+            'msToken': 'G8pL2oH-9Zl1hrLZPyOMSceMaII3ejKda2o-tgO1heYrj7b_fgm9vGlvwyLOA2H8oUShZgAYfxEvIuktT'
+                       '7OuxBuy85N-ousFfqxuAIrfruMEFZUTYp2z',
+            'tt_scid': 'a0zhISPImN-dVMMdbeb1Kzhl1x4oJS5Yr81FzH6qYk3jDtj1d2E5gsywN4rwna8ib398',
+            'ttwid': '1%7CvorN1HQjbSgBViRkEoZYEbqP_sQVoQqaUqGcFA-bzpA%7C1661324763%7Ce040213e1107973ebb0d'
+                     'b64f0e77cfb027375f1fb5854bb40588d692d025af1f',
+        }
+        urllib3.disable_warnings()
+        response = requests.get(url=url, headers=headers, params=params,
+                                cookies=cookies, proxies=proxies, verify=False)
+        cls.offset += 30
+        if 'data' not in response.text or response.json()['data'] == '' or response.json()['code'] != 200:
+            Common.logger(log_type).info('get_follow_feeds: response:{}', response.text)
+        else:
+            feeds = response.json()['data']['videoList']
+            return feeds
+        # except Exception as e:
+        #     Common.logger(log_type).error(f'get_feeds异常:{e}\n')
 
     # 下载 / 上传
     @classmethod
     def download_publish(cls, log_type, video_dict, our_id, env):
-        try:
-            if video_dict['gid'] == 0 or video_dict['video_id'] == 0 or video_dict['video_url'] == 0:
-                Common.logger(log_type).info('无效视频\n')
-            elif video_dict['is_top'] is True and int(time.time()) - int(video_dict['send_time']) > 3600 * 24 * 10:
-                Common.logger(log_type).info(
-                    f'置顶视频,'
-                    f'且发布时间超过10天:{time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(video_dict["send_time"]))}\n')
-            elif int(time.time()) - int(video_dict['send_time']) > 3600 * 24 * 10:
-                Common.logger(log_type).info(
-                    f'发布时间超过10天:{time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(video_dict["send_time"]))}\n')
-                cls.offset = 0
-                return
-            elif cls.download_rule(video_dict['video_duration'], video_dict['video_width'], video_dict['video_height']) is False:
-                Common.logger(log_type).info('不满足抓取规则\n')
-            elif any(word if word in video_dict['video_title'] else False for word in cls.filter_words(log_type)) is True:
-                Common.logger(log_type).info('标题已中过滤词:{}\n', video_dict['video_title'])
-            elif str(video_dict['video_id']) in [x for y in Feishu.get_values_batch(log_type, 'xigua', 'e075e9') for x in y]:
-                Common.logger(log_type).info('视频已下载\n')
-            elif str(video_dict['video_id']) in [x for y in Feishu.get_values_batch(log_type, 'xigua', '3Ul6wZ') for x in y]:
-                Common.logger(log_type).info('视频已下载\n')
-            elif str(video_dict['video_id']) in [x for y in Feishu.get_values_batch(log_type, 'xigua', 'QOWqMo') for x in y]:
-                Common.logger(log_type).info('视频已下载\n')
-            elif str(video_dict['video_id']) in [x for y in Feishu.get_values_batch(log_type, 'xigua', 'wjhpDs') for x in y]:
-                Common.logger(log_type).info('视频已存在\n')
+        # try:
+        if video_dict['gid'] == 0 or video_dict['video_id'] == 0 or video_dict['video_url'] == 0:
+            Common.logger(log_type).info('无效视频\n')
+        elif video_dict['is_top'] is True and int(time.time()) - int(video_dict['send_time']) > 3600 * 24 * 10:
+            Common.logger(log_type).info(
+                f'置顶视频,'
+                f'且发布时间超过10天:{time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(video_dict["send_time"]))}\n')
+        elif int(time.time()) - int(video_dict['send_time']) > 3600 * 24 * 10:
+            Common.logger(log_type).info(
+                f'发布时间超过10天:{time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(video_dict["send_time"]))}\n')
+            cls.offset = 0
+            return
+        elif cls.download_rule(video_dict['video_duration'], video_dict['video_width'], video_dict['video_height']) is False:
+            Common.logger(log_type).info('不满足抓取规则\n')
+        elif any(word if word in video_dict['video_title'] else False for word in cls.filter_words(log_type)) is True:
+            Common.logger(log_type).info('标题已中过滤词:{}\n', video_dict['video_title'])
+        elif str(video_dict['video_id']) in [x for y in Feishu.get_values_batch(log_type, 'xigua', 'e075e9') for x in y]:
+            Common.logger(log_type).info('视频已下载\n')
+        elif str(video_dict['video_id']) in [x for y in Feishu.get_values_batch(log_type, 'xigua', '3Ul6wZ') for x in y]:
+            Common.logger(log_type).info('视频已下载\n')
+        elif str(video_dict['video_id']) in [x for y in Feishu.get_values_batch(log_type, 'xigua', 'QOWqMo') for x in y]:
+            Common.logger(log_type).info('视频已下载\n')
+        elif str(video_dict['video_id']) in [x for y in Feishu.get_values_batch(log_type, 'xigua', 'wjhpDs') for x in y]:
+            Common.logger(log_type).info('视频已存在\n')
+        else:
+            # 下载封面
+            Common.download_method(log_type=log_type, text='cover', d_name=video_dict['video_title'],
+                                   d_url=video_dict['cover_url'])
+            # 下载视频
+            Common.download_method(log_type=log_type, text='video', d_name=video_dict['video_title'],
+                                   d_url=video_dict['video_url'])
+            # 下载音频
+            Common.download_method(log_type=log_type, text='audio', d_name=video_dict['video_title'],
+                                   d_url=video_dict['audio_url'])
+            # 保存视频信息至 "./videos/{download_video_title}/info.txt"
+            with open("./videos/" + video_dict['video_title'] + "/" + "info.txt",
+                      "a", encoding="UTF-8") as f_a:
+                f_a.write(str(video_dict['video_id']) + "\n" +
+                          str(video_dict['video_title']) + "\n" +
+                          str(video_dict['video_duration']) + "\n" +
+                          str(video_dict['play_cnt']) + "\n" +
+                          str(video_dict['comment_cnt']) + "\n" +
+                          str(video_dict['like_cnt']) + "\n" +
+                          str(video_dict['share_cnt']) + "\n" +
+                          str(video_dict['video_width'])+'*'+str(video_dict['video_height']) + "\n" +
+                          str(video_dict['send_time']) + "\n" +
+                          str(video_dict['user_name']) + "\n" +
+                          str(video_dict['head_url']) + "\n" +
+                          str(video_dict['video_url']) + "\n" +
+                          str(video_dict['cover_url']) + "\n" +
+                          "xigua" + str(int(time.time())))
+            Common.logger("follow").info("==========视频信息已保存至info.txt==========")
+            # 合成音视频
+            cls.video_compose(log_type, video_dict['video_title'])
+
+            # 上传视频
+            Common.logger(log_type).info("开始上传视频:{}".format(video_dict['video_title']))
+            our_video_id = Publish.upload_and_publish(log_type, env, our_id)
+            if env == 'dev':
+                our_video_link = "https://testadmin.piaoquantv.com/cms/post-detail/" + str(our_video_id) + "/info"
             else:
-                # 下载封面
-                Common.download_method(log_type=log_type, text='cover', d_name=video_dict['video_title'],
-                                       d_url=video_dict['cover_url'])
-                # 下载视频
-                Common.download_method(log_type=log_type, text='video', d_name=video_dict['video_title'],
-                                       d_url=video_dict['video_url'])
-                # 下载音频
-                Common.download_method(log_type=log_type, text='audio', d_name=video_dict['video_title'],
-                                       d_url=video_dict['audio_url'])
-                # 保存视频信息至 "./videos/{download_video_title}/info.txt"
-                with open("./videos/" + video_dict['video_title'] + "/" + "info.txt",
-                          "a", encoding="UTF-8") as f_a:
-                    f_a.write(str(video_dict['video_id']) + "\n" +
-                              str(video_dict['video_title']) + "\n" +
-                              str(video_dict['video_duration']) + "\n" +
-                              str(video_dict['play_cnt']) + "\n" +
-                              str(video_dict['comment_cnt']) + "\n" +
-                              str(video_dict['like_cnt']) + "\n" +
-                              str(video_dict['share_cnt']) + "\n" +
-                              str(video_dict['video_width'])+'*'+str(video_dict['video_height']) + "\n" +
-                              str(video_dict['send_time']) + "\n" +
-                              str(video_dict['user_name']) + "\n" +
-                              str(video_dict['head_url']) + "\n" +
-                              str(video_dict['video_url']) + "\n" +
-                              str(video_dict['cover_url']) + "\n" +
-                              "xigua" + str(int(time.time())))
-                Common.logger("follow").info("==========视频信息已保存至info.txt==========")
-                # 合成音视频
-                cls.video_compose(log_type, video_dict['video_title'])
-
-                # 上传视频
-                Common.logger(log_type).info("开始上传视频:{}".format(video_dict['video_title']))
-                our_video_id = Publish.upload_and_publish(log_type, env, our_id)
-                if env == 'dev':
-                    our_video_link = "https://testadmin.piaoquantv.com/cms/post-detail/" + str(our_video_id) + "/info"
-                else:
-                    our_video_link = "https://admin.piaoquantv.com/cms/post-detail/" + str(our_video_id) + "/info"
-                Common.logger(log_type).info("视频上传完成:{}\n", video_dict['video_title'])
-
-                # 视频ID工作表,插入首行
-                Feishu.insert_columns(log_type, 'xigua', "e075e9", "ROWS", 1, 2)
-                # 视频ID工作表,首行写入数据
-                upload_time = int(time.time())
-                values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(upload_time)),
-                           "关注榜",
-                           video_dict['video_title'],
-                           str(video_dict['video_id']),
-                           our_video_link,
-                           video_dict['gid'],
-                           video_dict['play_cnt'],
-                           video_dict['comment_cnt'],
-                           video_dict['like_cnt'],
-                           video_dict['share_cnt'],
-                           video_dict['video_duration'],
-                           str(video_dict['video_width'])+'*'+str(video_dict['video_height']),
-                           time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(video_dict['send_time'])),
-                           video_dict['user_name'],
-                           video_dict['user_id'],
-                           video_dict['head_url'],
-                           video_dict['cover_url'],
-                           video_dict['video_url'],
-                           video_dict['audio_url']]]
-                time.sleep(1)
-                Feishu.update_values(log_type, 'xigua', "e075e9", "F2:Z2", values)
-                Common.logger(log_type).info(f"视频已保存至云文档:{video_dict['video_title']}\n")
-        except Exception as e:
-            Common.logger(log_type).error(f'download_publish异常:{e}\n')
+                our_video_link = "https://admin.piaoquantv.com/cms/post-detail/" + str(our_video_id) + "/info"
+            Common.logger(log_type).info("视频上传完成:{}\n", video_dict['video_title'])
+
+            # 视频ID工作表,插入首行
+            Feishu.insert_columns(log_type, 'xigua', "e075e9", "ROWS", 1, 2)
+            # 视频ID工作表,首行写入数据
+            upload_time = int(time.time())
+            values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(upload_time)),
+                       "关注榜",
+                       video_dict['video_title'],
+                       str(video_dict['video_id']),
+                       our_video_link,
+                       video_dict['gid'],
+                       video_dict['play_cnt'],
+                       video_dict['comment_cnt'],
+                       video_dict['like_cnt'],
+                       video_dict['share_cnt'],
+                       video_dict['video_duration'],
+                       str(video_dict['video_width'])+'*'+str(video_dict['video_height']),
+                       time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(video_dict['send_time'])),
+                       video_dict['user_name'],
+                       video_dict['user_id'],
+                       video_dict['head_url'],
+                       video_dict['cover_url'],
+                       video_dict['video_url'],
+                       video_dict['audio_url']]]
+            time.sleep(1)
+            Feishu.update_values(log_type, 'xigua', "e075e9", "F2:Z2", values)
+            Common.logger(log_type).info(f"视频已保存至云文档:{video_dict['video_title']}\n")
+        # except Exception as e:
+        #     Common.logger(log_type).error(f'download_publish异常:{e}\n')
 
     @classmethod
     def get_videos(cls, log_type, out_id, our_id, env):
@@ -561,19 +561,19 @@ class Follow:
     # 获取所有用户主页视频
     @classmethod
     def get_all_person_videos(cls, log_type, env):
-        try:
-            user_list = cls.get_user_info_from_feishu(log_type)
-            if len(user_list) == 0:
-                Common.logger(log_type).warning('用户ID列表为空\n')
-            else:
-                for k, v in user_list.items():
-                    Common.logger(log_type).info('正在获取 {} 主页视频\n', k)
-                    GetSignature.get_signature('follow')
-                    cls.get_videos(log_type, v.split(',')[0], v.split(',')[1], env)
-                    time.sleep(10)
-                    cls.offset = 0
-        except Exception as e:
-            Common.logger(log_type).error('get_all_person_videos异常:{}\n', e)
+        # try:
+        user_list = cls.get_user_info_from_feishu(log_type)
+        if len(user_list) == 0:
+            Common.logger(log_type).warning('用户ID列表为空\n')
+        else:
+            for k, v in user_list.items():
+                Common.logger(log_type).info('正在获取 {} 主页视频\n', k)
+                GetSignature.get_signature('follow')
+                cls.get_videos(log_type, v.split(',')[0], v.split(',')[1], env)
+                time.sleep(10)
+                cls.offset = 0
+        # except Exception as e:
+        #     Common.logger(log_type).error('get_all_person_videos异常:{}\n', e)
 
 
 if __name__ == '__main__':

+ 3 - 2
main/xigua_publish.py

@@ -62,10 +62,11 @@ class Publish:
         versionCode  版本 默认1
         :return:
         """
+        Common.logger(log_type).info(f'publish request data: {request_data}')
         result = cls.request_post('https://longvideoapi.piaoquantv.com/longvideoapi/crawler/video/send', request_data)
-        # Common.logger(log_type).info('publish result: {}'.format(result))
+        Common.logger(log_type).info(f'publish result: {result}')
         video_id = result["data"]["id"]
-        # Common.logger(log_type).info('video_id: {}'.format(video_id))
+        Common.logger(log_type).info(f'video_id: {video_id}')
         if result['code'] != 0:
             Common.logger(log_type).error('pushlish failure msg = {}'.format(result['msg']))
         else: