From 73611d4d43bab0da17d6c82805c43986bb0505a0 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Fri, 31 Jul 2020 19:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=88=98=E6=97=97=E7=9B=B4?= =?UTF-8?q?=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhanqi.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/zhanqi.py b/zhanqi.py index e77e6b7..d32be97 100644 --- a/zhanqi.py +++ b/zhanqi.py @@ -1,24 +1,25 @@ -# 获取战旗直播(战旗TV)的真实流媒体地址。 -# 默认画质为超清 - - +# 获取战旗直播(战旗TV)的真实流媒体地址。https://www.zhanqi.tv/lives +# 默认最高画质 import requests -def get_real_url(rid): - room_url = 'https://m.zhanqi.tv/api/static/v2.1/room/domain/' + str(rid) + '.json' - try: - response = requests.get(url=room_url).json() - videoId = response.get('data').get('videoId') - if videoId: - real_url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/' + str(videoId) + '.flv' - else: - real_url = '未开播' - except: - real_url = '直播间不存在' - return real_url +def zhanqi(rid): + with requests.Session() as s: + res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(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: + real_url = '未开播' + except: + real_url = '直播间不存在' + return real_url -rid = input('请输入战旗直播房间号:\n') -real_url = get_real_url(rid) -print('该直播间源地址为:\n' + real_url) +if __name__ == '__main__': + r = input('输入战旗直播房间号:\n') + print(zhanqi(r))