mirror of
https://github.com/wbt5/real-url.git
synced 2025-06-16 15:59:57 +08:00
⚡ Improve 战旗直播
-添加特殊直播间的获取 -优化代码
This commit is contained in:
parent
4cb2edc05a
commit
a82ce4b08f
19
zhanqi.py
19
zhanqi.py
@ -2,6 +2,7 @@
|
||||
# 默认最高画质
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
import requests
|
||||
|
||||
@ -9,12 +10,18 @@ import requests
|
||||
class ZhanQi:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
"""
|
||||
战旗直播间有两种:一种是普通直播间号为数字或字幕;另一种是官方的主题直播间,链接带topic。
|
||||
所以先判断一次后从网页源代码里获取数字直播间号
|
||||
Args:
|
||||
rid:直播间链接,从网页源码里获取真实数字rid
|
||||
"""
|
||||
self.s = requests.Session()
|
||||
res = self.s.get(rid).text
|
||||
self.rid = re.search(r'"code":"(\d+)"', res).group(1)
|
||||
|
||||
def get_real_url(self):
|
||||
|
||||
res = self.s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
|
||||
res = self.s.get(f'https://m.zhanqi.tv/api/static/v2.1/room/domain/{self.rid}.json')
|
||||
try:
|
||||
res = res.json()
|
||||
videoid = res['data']['videoId']
|
||||
@ -47,8 +54,7 @@ class ZhanQi:
|
||||
res = self.s.post('https://www.zhanqi.tv/api/public/burglar/chain', data=data, headers=headers).json()
|
||||
chain_key = res['data']['key']
|
||||
url = f'https://{cdn_host}/alhdl-cdn.zhanqi.tv/zqlive/{videoid}.flv?{chain_key}&playNum=68072487067' \
|
||||
f'&gId={gid}&ipFrom=1&clientIp=&fhost=h5&platform=128 '
|
||||
|
||||
f'&gId={gid}&ipFrom=1&clientIp=&fhost=h5&platform=128'
|
||||
return url
|
||||
else:
|
||||
raise Exception('No streaming')
|
||||
@ -64,5 +70,6 @@ def get_real_url(rid):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入战旗直播房间号:\n')
|
||||
# 直播间链接类似:https://www.zhanqi.tv/topic/owl 或 https://www.zhanqi.tv/152600919
|
||||
r = input('输入战旗直播间的链接:\n')
|
||||
print(get_real_url(r))
|
||||
|
Loading…
x
Reference in New Issue
Block a user