From 14e2cf7817b7c237eeb152f6edb9e04f24c2f7ea Mon Sep 17 00:00:00 2001 From: wbt5 Date: Sat, 13 Nov 2021 00:35:35 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=20?= =?UTF-8?q?=E4=BD=93=E8=82=B2=E7=9B=B4=E6=92=ADTV(#166)=20-=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A4=B4=20-=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhibotv.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/zhibotv.py b/zhibotv.py index 401f890..dc2071f 100644 --- a/zhibotv.py +++ b/zhibotv.py @@ -10,16 +10,25 @@ import requests class ZhiBotv: def __init__(self, rid): + """ + 中国体育&新传宽频,直播间地址如:https://v.zhibo.tv/10007 + Args: + rid:房间号 + """ self.rid = rid self.params = { - 'token': '', 'roomId': self.rid, 'angleId': '', 'lineId': '', 'definition': 'hd', 'statistics': 'pc|web|1.0.0|0|0|0|local|5.0.1', - + } + self.BASE_URL = 'https://rest.zhibo.tv/room/get-pull-stream-info-v430' + self.HEADERS = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' + 'Chrome/95.0.4638.69 Safari/537.36 ', + 'Referer': 'https://www.zhibo.tv/live/' } def get_real_url(self): @@ -29,7 +38,7 @@ class ZhiBotv: :return: url """ with requests.Session() as s: - res = s.get('https://rest.zhibo.tv/room/get-pull-stream-info-v430', params=self.params).json() + res = s.get(self.BASE_URL, params=self.params, headers=self.HEADERS).json() if 'hlsHUrl' in res['data']: url = res['data'].get('hlsHUrl') if url: