From eb67046e6aae2604420d6eb3c3e7c536edb4b7e4 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Fri, 31 Jul 2020 19:40:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BA=A2=E4=BA=BA=E7=9B=B4?= =?UTF-8?q?=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hongle.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 hongle.py diff --git a/hongle.py b/hongle.py new file mode 100644 index 0000000..20b9310 --- /dev/null +++ b/hongle.py @@ -0,0 +1,43 @@ +# 红人直播:https://www.hongle.tv/ +from urllib.parse import urlencode +import requests +import time +import hashlib + + +def hongle(rid): + url = 'https://service.hongle.tv/v2/roomw/media' + accesstoken = 'YeOucg9SmlbeeicDSN9k0efa4JaecMNbQd7eTQDNQRRmqUHnA%2Bwq4g%3D%3D' + params = { + '_st1': int(time.time() * 1000), + 'accessToken': accesstoken, + 'of': 1, + 'showid': rid, + 'tku': 44623062, + } + data = urlencode(params) + 'yuj1ah5o' + _ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest() + params['_ajaxData1'] = _ajaxData1 + params['accessToken'] = 'YeOucg9SmlbeeicDSN9k0efa4JaecMNbQd7eTQDNQRRmqUHnA+wq4g==' + with requests.Session() as s: + res = s.get(url, params=params) + if res.status_code == 200: + res = res.json() + statuscode = res['status']['statuscode'] + if statuscode == '0': + if res['data']['live_status'] == '1': + real_url = res['data']['media_url_web'] + real_url = real_url.replace('http', 'https') + real_url = real_url.replace('__', '&') + return real_url + else: + raise Exception('未开播') + else: + raise Exception('房间不存在') + else: + raise Exception('参数错误') + + +if __name__ == '__main__': + r = input('输入红人直播房间号:\n') + print(hongle(r))