fix(tiktok): 优化视频链接获取

This commit is contained in:
imgyh 2023-04-21 20:18:56 +08:00
parent a984186542
commit 321d4622a1
2 changed files with 7 additions and 11 deletions

View File

@ -418,8 +418,7 @@ class TikTok(object):
# 分区
self.result.liveDict["partition"] = live_json['data']['partition_road_map']['partition']['title']
self.result.liveDict["sub_partition"] = \
live_json['data']['partition_road_map']['sub_partition']['partition'][
'title']
live_json['data']['partition_road_map']['sub_partition']['partition']['title']
except Exception as e:
self.result.liveDict["partition"] = ''
self.result.liveDict["sub_partition"] = ''
@ -429,8 +428,7 @@ class TikTok(object):
for i, f in enumerate(self.result.liveDict["flv_pull_url"].keys()):
flv.append(f)
self.result.liveDict["flv_pull_url0"] = self.result.liveDict["flv_pull_url"][flv[0]].replace("http://",
"https://")
self.result.liveDict["flv_pull_url0"] = self.result.liveDict["flv_pull_url"][flv[0]]
return self.result.liveDict, live_json
@ -498,8 +496,7 @@ class TikTok(object):
# 分区
self.result.liveDict["partition"] = live_json['data']['partition_road_map']['partition']['title']
self.result.liveDict["sub_partition"] = \
live_json['data']['partition_road_map']['sub_partition']['partition'][
'title']
live_json['data']['partition_road_map']['sub_partition']['partition']['title']
except Exception as e:
self.result.liveDict["partition"] = ''
self.result.liveDict["sub_partition"] = ''
@ -517,8 +514,7 @@ class TikTok(object):
rate = int(input('[ 🎬 ]输入数字选择推流清晰度:'))
self.result.liveDict["flv_pull_url0"] = self.result.liveDict["flv_pull_url"][flv[rate]].replace("http://",
"https://")
self.result.liveDict["flv_pull_url0"] = self.result.liveDict["flv_pull_url"][flv[rate]]
# 显示清晰度列表
print('[ %s ]:%s' % (flv[rate], self.result.liveDict["flv_pull_url"][flv[rate]]))
@ -949,7 +945,7 @@ class TikTok(object):
pass
else:
try:
url = awemeDict["video"]["play_addr"]["url_list"]
url = awemeDict["video"]["play_addr"]["url_list"][0]
if url != "":
self.isdwownload = False
# task_id = self.progress.add_task("download", filename="[ 视频 ]:" + desc, start=False)

View File

@ -121,7 +121,7 @@ class Result(object):
self.videoDict = {
"play_addr": {
"uri": "",
"url_list": "",
"url_list": [],
},
"cover_original_scale": {
"height": "",
@ -259,7 +259,7 @@ class Result(object):
# 使用 这个api 可以获得1080p
# dataNew[item]["url_list"] = "https://aweme.snssdk.com/aweme/v1/play/?video_id=%s&ratio=1080p&line=0" \
# % dataNew[item]["uri"]
dataNew[item]["url_list"] = dataRaw["bit_rate"][0]["play_addr"]["url_list"][0]
dataNew[item]["url_list"] = copy.deepcopy(dataRaw["bit_rate"][0]["play_addr"]["url_list"])
continue
# 常规 递归遍历 字典