mirror of
https://github.com/wbt5/real-url.git
synced 2025-08-02 15:44:49 +08:00
parent
f842ae68bc
commit
61e84a9eca
53
zhanqi.py
53
zhanqi.py
@ -1,5 +1,8 @@
|
|||||||
# 获取战旗直播(战旗TV)的真实流媒体地址。https://www.zhanqi.tv/lives
|
# 获取战旗直播(战旗TV)的真实流媒体地址。https://www.zhanqi.tv/lives
|
||||||
# 默认最高画质
|
# 默认最高画质
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
@ -7,22 +10,48 @@ class ZhanQi:
|
|||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
self.rid = rid
|
self.rid = rid
|
||||||
|
self.s = requests.Session()
|
||||||
|
|
||||||
def get_real_url(self):
|
def get_real_url(self):
|
||||||
with requests.Session() as s:
|
|
||||||
res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
|
res = self.s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
|
||||||
|
try:
|
||||||
|
res = res.json()
|
||||||
|
videoid = res['data']['videoId']
|
||||||
|
status = res['data']['status']
|
||||||
|
except (KeyError, json.decoder.JSONDecodeError):
|
||||||
|
raise Exception('Incorrect rid')
|
||||||
|
|
||||||
|
if status == '4':
|
||||||
|
# 获取gid
|
||||||
|
res = self.s.get('https://www.zhanqi.tv/api/public/room.viewer')
|
||||||
try:
|
try:
|
||||||
res = res.json()
|
res = res.json()
|
||||||
videoid = res['data']['videoId']
|
gid = res['data']['gid']
|
||||||
status = res['data']['status']
|
except KeyError:
|
||||||
if status == '4':
|
raise Exception('Getting gid incorrectly')
|
||||||
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
|
|
||||||
real_url = s.get(url).text
|
# 获取cdn_host
|
||||||
else:
|
res = self.s.get('https://umc.danuoyi.alicdn.com/dns_resolve_https?app=zqlive&host_key=alhdl-cdn.zhanqi.tv')
|
||||||
raise Exception('未开播')
|
cdn_host, = res.json().get('redirect_domain')
|
||||||
except:
|
|
||||||
raise Exception('直播间不存在')
|
# 获取chain_key
|
||||||
return real_url
|
data = {
|
||||||
|
'stream': f'{videoid}.flv',
|
||||||
|
'cdnKey': 202,
|
||||||
|
'platform': 128,
|
||||||
|
}
|
||||||
|
headers = {
|
||||||
|
'cookie': f'gid={gid}',
|
||||||
|
}
|
||||||
|
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 '
|
||||||
|
|
||||||
|
return url
|
||||||
|
else:
|
||||||
|
raise Exception('No streaming')
|
||||||
|
|
||||||
|
|
||||||
def get_real_url(rid):
|
def get_real_url(rid):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user