mirror of
https://github.com/wbt5/real-url.git
synced 2025-07-26 02:21:43 +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 json
|
||||||
|
import re
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@ -9,12 +10,18 @@ import requests
|
|||||||
class ZhanQi:
|
class ZhanQi:
|
||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
self.rid = rid
|
"""
|
||||||
|
战旗直播间有两种:一种是普通直播间号为数字或字幕;另一种是官方的主题直播间,链接带topic。
|
||||||
|
所以先判断一次后从网页源代码里获取数字直播间号
|
||||||
|
Args:
|
||||||
|
rid:直播间链接,从网页源码里获取真实数字rid
|
||||||
|
"""
|
||||||
self.s = requests.Session()
|
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):
|
def get_real_url(self):
|
||||||
|
res = self.s.get(f'https://m.zhanqi.tv/api/static/v2.1/room/domain/{self.rid}.json')
|
||||||
res = self.s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
|
|
||||||
try:
|
try:
|
||||||
res = res.json()
|
res = res.json()
|
||||||
videoid = res['data']['videoId']
|
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()
|
res = self.s.post('https://www.zhanqi.tv/api/public/burglar/chain', data=data, headers=headers).json()
|
||||||
chain_key = res['data']['key']
|
chain_key = res['data']['key']
|
||||||
url = f'https://{cdn_host}/alhdl-cdn.zhanqi.tv/zqlive/{videoid}.flv?{chain_key}&playNum=68072487067' \
|
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
|
return url
|
||||||
else:
|
else:
|
||||||
raise Exception('No streaming')
|
raise Exception('No streaming')
|
||||||
@ -64,5 +70,6 @@ def get_real_url(rid):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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))
|
print(get_real_url(r))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user