mirror of
https://github.com/imgyh/tiktok.git
synced 2025-04-06 00:07:14 +08:00
feat(live): 适配web端的直播解析
This commit is contained in:
parent
2183ebdb41
commit
f7fdcd141b
16
TikTok.py
16
TikTok.py
@ -202,7 +202,7 @@ class TikTok(object):
|
||||
|
||||
return awemeList
|
||||
|
||||
def getLiveInfo(self, web_rid: str):
|
||||
def getLiveInfo(self, web_rid: str, option=True):
|
||||
print('[ 提示 ]:正在请求的直播间 id = %s\r\n' % web_rid)
|
||||
|
||||
# web_rid = live_url.replace('https://live.douyin.com/', '')
|
||||
@ -224,6 +224,8 @@ class TikTok(object):
|
||||
# 清空字典
|
||||
self.result.clearDict(self.result.liveDict)
|
||||
|
||||
# 类型
|
||||
self.result.liveDict["awemeType"] = 2
|
||||
# 是否在播
|
||||
self.result.liveDict["status"] = live_json['data']['data'][0]['status']
|
||||
|
||||
@ -234,6 +236,12 @@ class TikTok(object):
|
||||
# 直播标题
|
||||
self.result.liveDict["title"] = live_json['data']['data'][0]['title']
|
||||
|
||||
# 直播cover
|
||||
self.result.liveDict["cover"] = live_json['data']['data'][0]['cover']['url_list'][0]
|
||||
|
||||
# 头像
|
||||
self.result.liveDict["avatar"] = live_json['data']['data'][0]['owner']['avatar_thumb']['url_list'][0].replace("100x100", "1080x1080")
|
||||
|
||||
# 观看人数
|
||||
self.result.liveDict["user_count"] = live_json['data']['data'][0]['user_count_str']
|
||||
|
||||
@ -268,8 +276,12 @@ class TikTok(object):
|
||||
for i, f in enumerate(self.result.liveDict["flv_pull_url"].keys()):
|
||||
print('[ %s ]: %s' % (i, f))
|
||||
flv.append(f)
|
||||
if option:
|
||||
rate = int(input('[ 🎬 ]输入数字选择推流清晰度:'))
|
||||
else:
|
||||
rate = 0
|
||||
|
||||
rate = int(input('[ 🎬 ]输入数字选择推流清晰度:'))
|
||||
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]]))
|
||||
|
@ -151,7 +151,7 @@ class Result(object):
|
||||
self.awemeDict = {
|
||||
# 作品创建时间
|
||||
"create_time": "",
|
||||
# awemeType=0 视频, awemeType=1 图集
|
||||
# awemeType=0 视频, awemeType=1 图集, awemeType=2 直播
|
||||
"awemeType": "",
|
||||
# 作品 id
|
||||
"aweme_id": "",
|
||||
@ -179,10 +179,16 @@ class Result(object):
|
||||
self.awemeList = []
|
||||
# 直播信息
|
||||
self.liveDict = {
|
||||
# awemeType=0 视频, awemeType=1 图集, awemeType=2 直播
|
||||
"awemeType": "",
|
||||
# 是否在播
|
||||
"status": "",
|
||||
# 直播标题
|
||||
"title": "",
|
||||
# 直播cover
|
||||
"cover": "",
|
||||
# 头像
|
||||
"avatar": "",
|
||||
# 观看人数
|
||||
"user_count": "",
|
||||
# 昵称
|
||||
@ -195,7 +201,9 @@ class Result(object):
|
||||
"flv_pull_url": "",
|
||||
# 分区
|
||||
"partition": "",
|
||||
"sub_partition": ""
|
||||
"sub_partition": "",
|
||||
# 最清晰的地址
|
||||
"flv_pull_url0": "",
|
||||
}
|
||||
|
||||
# 将得到的json数据(dataRaw)精简成自己定义的数据(dataNew)
|
||||
|
@ -22,7 +22,10 @@ def work(share_link):
|
||||
|
||||
url = tk.getShareLink(share_link)
|
||||
key_type, key = tk.getKey(url)
|
||||
datanew, dataraw = tk.getAwemeInfo(key)
|
||||
if key_type == "aweme":
|
||||
datanew, dataraw = tk.getAwemeInfo(key)
|
||||
elif key_type == "live":
|
||||
datanew = tk.getLiveInfo(key, option=False)
|
||||
return datanew
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user