Skip to content

Commit

Permalink
🕹1、修改了接口的参数 2、直接获取bit_rate最清晰的视频 #398 #399
Browse files Browse the repository at this point in the history
1、不然无法获取bit_rate中的清晰度选项
2、[0]为最高清晰度
  • Loading branch information
Johnserf-Seed committed Apr 20, 2023
1 parent 600cbf7 commit 6f3bc38
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Util/Images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
# 防止接口多次返回空
Expand Down
20 changes: 14 additions & 6 deletions Util/Profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -243,7 +245,9 @@ def getVideoInfo(self, result):
# 作品id
self.aweme_id = []
# 唯一视频标识
self.uri_list = []
# self.uri_list = []
# 视频播放地址
self.url_list = []
# 图集
self.image_list = []
# 封面大图
Expand All @@ -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]))
Expand Down

0 comments on commit 6f3bc38

Please sign in to comment.