Skip to content

Commit

Permalink
@whitebeard916 感谢反馈,修复了图集接口会返回空的情况 #381 #377 #370 #357
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnserf-Seed committed Apr 3, 2023
1 parent 6aa5a74 commit 89af446
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Util/Images.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


class Images():
def __init__(self):
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
Expand All @@ -38,10 +38,7 @@ def __init__(self):
# 图集链接
self.images = []
# headers
self.headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36',
'referer':'https://www.douyin.com/'
}
self.headers = headers


def get_all_images(self, aweme_id):
Expand All @@ -51,6 +48,9 @@ def get_all_images(self, aweme_id):
f'aweme_id={id}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333').params

r = Util.requests.get(url=jx_url, headers=self.headers).text
# 防止接口多次返回空
while r == '':
r = Util.requests.get(url=jx_url, headers=self.headers).text
js = Util.json.loads(r)

self.nickname = js['aweme_detail']['author']['nickname']
Expand Down
2 changes: 1 addition & 1 deletion Util/Profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def getVideoInfo(self, result):
# 输出日志
Util.log.info('[ 提示 ]:正在替换作者非法字符,耐心等待!')
# 下载主页所有图集
datas = Util.Images().get_all_images(self.image_list)
datas = Util.Images(self.headers).get_all_images(self.image_list)
Util.Download().VideoDownload(self)
Util.Download().ImageDownload(datas)
self.getNextData()
Expand Down

0 comments on commit 89af446

Please sign in to comment.