From 63bb22457f191c33ef7c8a8f697cbe3d592a01ca Mon Sep 17 00:00:00 2001 From: wbt5 Date: Sun, 15 Aug 2021 16:15:31 +0800 Subject: [PATCH] :sparkles: Add LiveU (#243) --- liveu.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 liveu.py diff --git a/liveu.py b/liveu.py new file mode 100644 index 0000000..152210e --- /dev/null +++ b/liveu.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# @Time: 2021/8/15 14:09 +# @Project: my-spiders +# @Author: wbt5 +# @Blog: https://wbt5.com + +import requests + + +class liveU: + + def __init__(self, rid): + self.rid = rid + + def get_real_url(self): + with requests.Session() as s: + url = f'https://mobile.liveu.me/appgw/v2/watchstartweb?sessionid=&vid={self.rid}' + res = s.get(url).json() + play_url = res['retinfo']['play_url'] if res['retval'] == 'ok' else '不存在或未开播' + return play_url + + +def get_real_url(rid): + try: + url = liveU(rid) + return url.get_real_url() + except Exception as e: + print('Exception:', e) + return False + + +if __name__ == '__main__': + r = input('输入liveU直播房间号:\n') + print(get_real_url(r))