Skip to content

Commit

Permalink
🎃更新调用XB方法
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnserf-Seed committed Jun 9, 2023
1 parent 54bd258 commit bb6b1b6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions TikTokDownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def video_download(url, music, name, headers):
# 此ies domian暂时不需要xg参数
# 单作品接口 'aweme_detail'
# 主页作品 'aweme_list'
jx_url = Util.Urls().POST_DETAIL + Util.XBogus(
f'aweme_id={key}&aid=6383&cookie_enabled=true&platform=PC&downlink=10').params
jx_url = Util.Urls().POST_DETAIL + Util.XBogus().getXBogus(
f'aweme_id={key}&aid=6383&cookie_enabled=true&platform=PC&downlink=10')[0]

js = Util.requests.get(
url=jx_url, headers=headers).text
Expand Down
3 changes: 1 addition & 2 deletions TikTokPic.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def pic_download(urlarg, headers):
# 此ies domian暂时不需要xg参数
# 单作品接口 'aweme_detail'
# 主页作品 'aweme_list'
jx_url = Urls().POST_DETAIL + XBogus(
f'aweme_id={key}&aid=6383&cookie_enabled=true&platform=PC&downlink=10').params
jx_url = Urls().POST_DETAIL + XBogus().getXBogus(f'aweme_id={key}&aid=6383&cookie_enabled=true&platform=PC&downlink=10')[0]

js = requests.get(
url=jx_url, headers=headers).text
Expand Down
6 changes: 4 additions & 2 deletions Util/Download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Download():

def __init__(self):
self.urls = Util.Urls()
# XB
self.XB = Util.XBogus()

def VideoDownload(self, profileData):
self.headers = profileData.headers
Expand Down Expand Up @@ -67,8 +69,8 @@ def VideoDownload(self, profileData):
# 单作品接口 'aweme_detail'
# 主页作品 'aweme_list'
# 23/02/09 更新xg参数
jx_url = Util.Urls().POST_DETAIL + Util.XBogus(
f'aweme_id={self.aweme_id[i]}&aid=6383&cookie_enabled=true&platform=PC&downlink=10').params
jx_url = Util.Urls().POST_DETAIL + self.XB.getXBogus(
f'aweme_id={self.aweme_id[i]}&aid=6383&cookie_enabled=true&platform=PC&downlink=10')[0]
js = Util.requests.get(
url=jx_url, headers=self.headers).text
# 防止接口多次返回空
Expand Down
6 changes: 4 additions & 2 deletions Util/Images.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ def __init__(self, headers):
self.images = []
# headers
self.headers = headers
# XB
self.XB = Util.XBogus()


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=6383&cookie_enabled=true&platform=PC&downlink=10').params
jx_url = Util.Urls().POST_DETAIL + self.XB.getXBogus(
f'aweme_id={id}&aid=6383&cookie_enabled=true&platform=PC&downlink=10')[0]

r = Util.requests.get(url=jx_url, headers=self.headers).text
# 防止接口多次返回空
Expand Down
2 changes: 1 addition & 1 deletion Util/Lives.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_Live(live_url:str):
web_rid = live_url.replace('https://live.douyin.com/','')
# 2023/02/06 https://live.douyin.com/webcast/room/web/enter/

live_api = Util.Urls().LIVE + Util.XBogus('aid=6383&device_platform=web&web_rid=%s' % (web_rid)).params
live_api = Util.Urls().LIVE + Util.XBogus().getXBogus('aid=6383&device_platform=web&web_rid=%s' % (web_rid))[0]
# 获取命令行参数
cmd = Util.Command()
# 获取headers
Expand Down
18 changes: 10 additions & 8 deletions Util/Profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def __init__(self, headers):
Util.log.info(Util.platform.system())
# 接口
self.urls = Util.Urls()
# XB
self.XB = Util.XBogus()

def getProfile(self, param):
"""判断个人主页api链接
Expand Down Expand Up @@ -81,10 +83,10 @@ def getProfile(self, param):
# datas 为元组 (params, xb)
# 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' % (
datas = self.XB.getXBogus('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)
url=self.urls.USER_POST + datas[0], headers=self.headers, timeout=3)

if response.text == '':
input('[ 提示 ]:获取用户数据失败,请从web端获取新ttwid填入配置文件\r')
Expand All @@ -111,12 +113,12 @@ def getProfile(self, param):
exit()

# 构造第一次访问链接
datas = Util.XBogus('aid=6383&sec_user_id=%s&count=35&max_cursor=0&cookie_enabled=true&platform=PC&downlink=10' % (
datas = self.XB.getXBogus('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
self.api_post_url = self.urls.USER_POST + datas[0]
else:
self.api_post_url = self.urls.USER_FAVORITE_A + datas.params
self.api_post_url = self.urls.USER_FAVORITE_A + datas[0]

# 创建用户文件夹
self.path = "." + self.sprit + "Download" + self.sprit + \
Expand Down Expand Up @@ -190,13 +192,13 @@ def getData(self, api_post_url):
def getNextData(self):
"""获取下一页api数据
"""
datas = Util.XBogus('aid=6383&sec_user_id=%s&count=35&max_cursor=%s&cookie_enabled=true&platform=PC&downlink=10' % (
datas = self.XB.getXBogus('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':
api_naxt_post_url = self.urls.USER_POST + datas.params
api_naxt_post_url = self.urls.USER_POST + datas[0]
else:
api_naxt_post_url = self.urls.USER_FAVORITE_A + datas.params
api_naxt_post_url = self.urls.USER_FAVORITE_A + datas[0]

index = 0
result = []
Expand Down

0 comments on commit bb6b1b6

Please sign in to comment.