From 6f3bc38e26d6e3d43b590d4f4d81be1b4ba9c55c Mon Sep 17 00:00:00 2001 From: JohnserfSeed Date: Fri, 21 Apr 2023 00:12:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=95=B91=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E6=8E=A5=E5=8F=A3=E7=9A=84=E5=8F=82=E6=95=B0=202?= =?UTF-8?q?=E3=80=81=E7=9B=B4=E6=8E=A5=E8=8E=B7=E5=8F=96bit=5Frate?= =?UTF-8?q?=E6=9C=80=E6=B8=85=E6=99=B0=E7=9A=84=E8=A7=86=E9=A2=91=20#398?= =?UTF-8?q?=20#399?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、不然无法获取bit_rate中的清晰度选项 2、[0]为最高清晰度 --- Util/Images.py | 4 ++-- Util/Profile.py | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Util/Images.py b/Util/Images.py index 8407e87..3dbc0d8 100644 --- a/Util/Images.py +++ b/Util/Images.py @@ -22,7 +22,7 @@ class Images(): def __init__(self, headers): # 作品接口 self.apiUrl = Util.Urls().POST_DETAIL - # 'aweme_id={id}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333' # 作品id + # 'aweme_id={id}&aid=6383&cookie_enabled=true&platform=PC&downlink=10' # 作品id # 作品id self.aweme_id = '' # 作者id @@ -45,7 +45,7 @@ def get_all_images(self, aweme_id): datas = [] for id in aweme_id: jx_url = Util.Urls().POST_DETAIL + Util.XBogus( - f'aweme_id={id}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333').params + f'aweme_id={id}&aid=6383&cookie_enabled=true&platform=PC&downlink=10').params r = Util.requests.get(url=jx_url, headers=self.headers).text # 防止接口多次返回空 diff --git a/Util/Profile.py b/Util/Profile.py index 3fd8f34..920a258 100644 --- a/Util/Profile.py +++ b/Util/Profile.py @@ -79,7 +79,9 @@ def getProfile(self, param): # 23/02/09 # 获取xg参数 # datas 为元组 (params, xb) - datas = Util.XBogus('sec_user_id=%s&count=35&max_cursor=0&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333' % ( + # 23/04/20 + # 接口参数更新,旧的拿不到1080p了 + datas = Util.XBogus('aid=6383&sec_user_id=%s&count=35&max_cursor=0&cookie_enabled=true&platform=PC&downlink=10' % ( self.sec)) response = Util.requests.get( url=self.urls.USER_POST + datas.params, headers=self.headers, timeout=3) @@ -109,7 +111,7 @@ def getProfile(self, param): exit() # 构造第一次访问链接 - datas = Util.XBogus('sec_user_id=%s&count=35&max_cursor=0&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333' % ( + datas = Util.XBogus('aid=6383&sec_user_id=%s&count=35&max_cursor=0&cookie_enabled=true&platform=PC&downlink=10' % ( self.sec)) if self.mode == 'post': self.api_post_url = self.urls.USER_POST + datas.params @@ -188,7 +190,7 @@ def getData(self, api_post_url): def getNextData(self): """获取下一页api数据 """ - datas = Util.XBogus('sec_user_id=%s&count=35&max_cursor=%s&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333' % ( + datas = Util.XBogus('aid=6383&sec_user_id=%s&count=35&max_cursor=%s&cookie_enabled=true&platform=PC&downlink=10' % ( self.sec, self.max_cursor)) # 构造下一次访问链接 if self.mode == 'post': @@ -243,7 +245,9 @@ def getVideoInfo(self, result): # 作品id self.aweme_id = [] # 唯一视频标识 - self.uri_list = [] + # self.uri_list = [] + # 视频播放地址 + self.url_list = [] # 图集 self.image_list = [] # 封面大图 @@ -264,8 +268,12 @@ def getVideoInfo(self, result): # 拼接到 aweme.snssdk.com/aweme/v1/play/?video_id=xxxx&radio=1080p 则获取到1080p清晰的 # self.video_list.append( # str(result[v]['video']['play_addr']['url_list'][0])) - self.uri_list.append( - str(result[v]['video']['play_addr']['uri'])) + # 2023/04/20 1080p不再通过拼接uri获取 + # self.uri_list.append( + # str(result[v]['video']['play_addr']['uri'])) + # 2023/04/20 这是最新的1080p路径 + self.url_list.append( + str(result[v]['video']['bit_rate'][0]['play_addr']['url_list'][0])) self.aweme_id.append(str(result[v]['aweme_id'])) # nickname.append(str(result[v]['author']['nickname'])) # self.dynamic_cover.append(str(result[v]['video']['dynamic_cover']['url_list'][0]))