mirror of
https://github.com/imgyh/tiktok.git
synced 2025-05-04 20:11:36 +08:00
feat(live): 增加直播解析方法的提示信息开启或关闭选项
This commit is contained in:
parent
98a9f74d4b
commit
469fe2c521
@ -203,6 +203,7 @@ class TikTok(object):
|
|||||||
return awemeList
|
return awemeList
|
||||||
|
|
||||||
def getLiveInfo(self, web_rid: str, option=True):
|
def getLiveInfo(self, web_rid: str, option=True):
|
||||||
|
if option:
|
||||||
print('[ 提示 ]:正在请求的直播间 id = %s\r\n' % web_rid)
|
print('[ 提示 ]:正在请求的直播间 id = %s\r\n' % web_rid)
|
||||||
|
|
||||||
# web_rid = live_url.replace('https://live.douyin.com/', '')
|
# web_rid = live_url.replace('https://live.douyin.com/', '')
|
||||||
@ -214,10 +215,12 @@ class TikTok(object):
|
|||||||
response = requests.get(live_api, headers=self.headers)
|
response = requests.get(live_api, headers=self.headers)
|
||||||
live_json = json.loads(response.text)
|
live_json = json.loads(response.text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if option:
|
||||||
print("[ 错误 ]:接口未返回数据, 请检查后重新运行!\r")
|
print("[ 错误 ]:接口未返回数据, 请检查后重新运行!\r")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if live_json == {} or live_json['status_code'] != 0:
|
if live_json == {} or live_json['status_code'] != 0:
|
||||||
|
if option:
|
||||||
print("[ 错误 ]:接口未返回信息\r")
|
print("[ 错误 ]:接口未返回信息\r")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -230,6 +233,7 @@ class TikTok(object):
|
|||||||
self.result.liveDict["status"] = live_json['data']['data'][0]['status']
|
self.result.liveDict["status"] = live_json['data']['data'][0]['status']
|
||||||
|
|
||||||
if self.result.liveDict["status"] == 4:
|
if self.result.liveDict["status"] == 4:
|
||||||
|
if option:
|
||||||
print('[ 📺 ]:当前直播已结束,正在退出')
|
print('[ 📺 ]:当前直播已结束,正在退出')
|
||||||
return self.result.liveDict
|
return self.result.liveDict
|
||||||
|
|
||||||
@ -266,14 +270,17 @@ class TikTok(object):
|
|||||||
self.result.liveDict["partition"] = '无'
|
self.result.liveDict["partition"] = '无'
|
||||||
self.result.liveDict["sub_partition"] = '无'
|
self.result.liveDict["sub_partition"] = '无'
|
||||||
|
|
||||||
|
if option:
|
||||||
info = '[ 💻 ]:直播间:%s 当前%s 主播:%s 分区:%s-%s\r' % (
|
info = '[ 💻 ]:直播间:%s 当前%s 主播:%s 分区:%s-%s\r' % (
|
||||||
self.result.liveDict["title"], self.result.liveDict["display_long"], self.result.liveDict["nickname"],
|
self.result.liveDict["title"], self.result.liveDict["display_long"], self.result.liveDict["nickname"],
|
||||||
self.result.liveDict["partition"], self.result.liveDict["sub_partition"])
|
self.result.liveDict["partition"], self.result.liveDict["sub_partition"])
|
||||||
print(info)
|
print(info)
|
||||||
|
|
||||||
flv = []
|
flv = []
|
||||||
|
if option:
|
||||||
print('[ 🎦 ]:直播间清晰度')
|
print('[ 🎦 ]:直播间清晰度')
|
||||||
for i, f in enumerate(self.result.liveDict["flv_pull_url"].keys()):
|
for i, f in enumerate(self.result.liveDict["flv_pull_url"].keys()):
|
||||||
|
if option:
|
||||||
print('[ %s ]: %s' % (i, f))
|
print('[ %s ]: %s' % (i, f))
|
||||||
flv.append(f)
|
flv.append(f)
|
||||||
if option:
|
if option:
|
||||||
@ -284,8 +291,8 @@ class TikTok(object):
|
|||||||
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]].replace("http://", "https://")
|
||||||
|
|
||||||
# 显示清晰度列表
|
# 显示清晰度列表
|
||||||
|
if option:
|
||||||
print('[ %s ]:%s' % (flv[rate], self.result.liveDict["flv_pull_url"][flv[rate]]))
|
print('[ %s ]:%s' % (flv[rate], self.result.liveDict["flv_pull_url"][flv[rate]]))
|
||||||
|
|
||||||
print('[ 📺 ]:复制链接使用下载工具下载')
|
print('[ 📺 ]:复制链接使用下载工具下载')
|
||||||
return self.result.liveDict
|
return self.result.liveDict
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user