From a8f088b870fcebe70b6d80e5a4d73232ee237595 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Fri, 31 Jul 2020 19:38:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=98=9F=E5=85=89=E7=9B=B4?= =?UTF-8?q?=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tuho.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tuho.py diff --git a/tuho.py b/tuho.py new file mode 100644 index 0000000..32c8b06 --- /dev/null +++ b/tuho.py @@ -0,0 +1,23 @@ +# 星光直播:https://www.tuho.tv/28545037 +import requests +import re + + +def tuho(rid): + with requests.Session() as s: + res = s.get('https://www.tuho.tv/' + str(rid)).text + flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res) + if flv: + status = re.search(r'isPlaying\s:\s(\w+),', res).group(1) + if status == 'true': + real_url = flv.group(1).replace('\\', '') + return real_url + else: + raise Exception('未开播') + else: + raise Exception('直播间不存在') + + +if __name__ == '__main__': + r = input('输入星光直播房间号:\n') + print(tuho(r))