From d126f67d15b90336ce676080c582de6358e80992 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Fri, 31 Jul 2020 19:39:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=B7=E6=88=91=E8=81=9A?= =?UTF-8?q?=E6=98=9F=E7=9B=B4=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kuwo.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 kuwo.py diff --git a/kuwo.py b/kuwo.py new file mode 100644 index 0000000..333f4bb --- /dev/null +++ b/kuwo.py @@ -0,0 +1,22 @@ +# 酷我聚星直播:http://jx.kuwo.cn/ +import requests + + +def kuwo(rid): + with requests.Session() as s: + res = s.get('https://zhiboserver.kuwo.cn/proxy.p?src=h5&cmd=enterroom&rid={}&videotype=1&auto=1'.format(rid)) + res = res.json() + try: + livestatus = res['room']['livestatus'] + except KeyError: + raise Exception('房间号错误') + if livestatus == 2: + real_url = res['live']['url'] + return real_url + else: + raise Exception('未开播') + + +if __name__ == '__main__': + r = input('输入酷我聚星直播房间号:\n') + print(kuwo(r))