From fe32942cdb39aaa9cc326e1b76c793e54f45ecbe Mon Sep 17 00:00:00 2001 From: wbt5 Date: Fri, 31 Jul 2020 19:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=83=AD=E7=8C=AB=E7=9B=B4?= =?UTF-8?q?=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuanbobo.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 yuanbobo.py diff --git a/yuanbobo.py b/yuanbobo.py new file mode 100644 index 0000000..e54650e --- /dev/null +++ b/yuanbobo.py @@ -0,0 +1,23 @@ +# 热猫直播:https://zhibo.yuanbobo.com/ +import requests +import re + + +def yuanbobo(rid): + with requests.Session() as s: + res = s.get('https://zhibo.yuanbobo.com/' + str(rid)).text + stream_id = re.search(r"stream_id:\s+'(\d+)'", res) + if stream_id: + status = re.search(r"status:\s+'(\d)'", res).group(1) + if status == '1': + real_url = 'http://ks-hlslive.yuanbobo.com/live/{}/index.m3u8'.format(stream_id.group(1)) + return real_url + else: + raise Exception('未开播') + else: + raise Exception('直播间不存在') + + +if __name__ == '__main__': + r = input('输入热猫直播房间号:\n') + print(yuanbobo(r))