From 8ee49c50a056dda823a2ff5bbb66d9c016fd4f96 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Sat, 13 Nov 2021 20:42:45 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fix=20PPS=E5=A5=87=E7=A7=80=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=20-=E4=BF=AE=E5=A4=8D=E6=AD=A3=E5=88=99=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E5=8C=B9=E9=85=8D=E4=B8=8D=E5=88=B0anchor=5F?= =?UTF-8?q?id=E7=9A=84=E9=97=AE=E9=A2=98=20-=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pps.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/pps.py b/pps.py index 2d197bf..e2b4881 100644 --- a/pps.py +++ b/pps.py @@ -9,20 +9,36 @@ class PPS: def __init__(self, rid): self.rid = rid + self.BASE_URL = 'https://m-x.pps.tv/api/stream/getH5' + self.s = requests.Session() def get_real_url(self): + headers = { + 'Content-Type': 'application/x-www-form-urlencoded', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, ' + 'like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', + 'Referer': 'https://m-x.pps.tv/' + } + tt = int(time.time() * 1000) try: - response = requests.get('http://m-x.pps.tv/room/' + str(self.rid)).text - anchor_id = re.findall(r'anchor_id":(\d*),"online_uid', response)[0] - tt = int(time.time() * 1000) - url = 'http://m-x.pps.tv/api/stream/getH5?qd_tm={}&typeId=1&platform=7&vid=0&qd_vip=0&qd_uid={}&qd_ip=114.114.114.114&qd_vipres=0&qd_src=h5_xiu&qd_tvid=0&callback='.format(tt, anchor_id) - headers = { - 'Content-Type': 'application/x-www-form-urlencoded', - 'Referer': 'http://m-x.pps.tv/' + res = self.s.get(f'https://m-x.pps.tv/room/{self.rid}', headers=headers).text + anchor_id = re.findall(r'anchor_id":"(\d*)', res)[0] + params = { + 'qd_tm': tt, + 'typeId': 1, + 'platform': 7, + 'vid': 0, + 'qd_vip': 0, + 'qd_uid': anchor_id, + 'qd_ip': '114.114.114.114', + 'qd_vipres': 0, + 'qd_src': 'h5_xiu', + 'qd_tvid': 0, + 'callback': '', } - response = requests.get(url=url, headers=headers).text - real_url = re.findall(r'"hls":"(.*)","rate_list', response)[0] - except: + res = self.s.get(self.BASE_URL, headers=headers, params=params).text + real_url = re.findall(r'"hls":"(.*)","rate_list', res)[0] + except Exception: raise Exception('直播间不存在或未开播') return real_url