1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-12-16 23:10:29 +08:00
zhibo-url/zhanqi.py

40 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 获取战旗直播战旗TV的真实流媒体地址。https://www.zhanqi.tv/lives
# 默认最高画质
import requests
class ZhanQi:
def __init__(self, rid):
self.rid = rid
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))
try:
res = res.json()
videoid = res['data']['videoId']
status = res['data']['status']
if status == '4':
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
real_url = s.get(url).text
else:
raise Exception('未开播')
except:
raise Exception('直播间不存在')
return real_url
def get_real_url(rid):
try:
zq = ZhanQi(rid)
return zq.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('输入战旗直播房间号:\n')
print(get_real_url(r))