From 76fb0ed7d79df6380484c0738873abef50d10348 Mon Sep 17 00:00:00 2001 From: yangshizi Date: Wed, 27 Sep 2017 14:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DPandaTv=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=88=BF=E9=97=B4=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- danmu/Panda.py | 17 ++++------------- run.py | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/danmu/Panda.py b/danmu/Panda.py index be0c27c..44a3353 100644 --- a/danmu/Panda.py +++ b/danmu/Panda.py @@ -29,19 +29,10 @@ def _get_live_status(self): return j['videoinfo']['status'] == '2' def _prepare_env(self): roomId = self.url.split('/')[-1] or self.url.split('/')[-2] - url = 'http://www.panda.tv/ajax_chatroom?roomid=%s&_=%s'%(roomId, str(int(time.time()))) - roomInfo = requests.get(url).json() - url = 'http://api.homer.panda.tv/chatroom/getinfo' - params = { - 'rid': roomInfo['data']['rid'], - 'roomid': roomId, - 'retry': 0, - 'sign': roomInfo['data']['sign'], - 'ts': roomInfo['data']['ts'], - '_': int(time.time()), } - serverInfo = requests.get(url, params).json()['data'] - serverAddress = serverInfo['chat_addr_list'][0].split(':') - return (serverAddress[0], int(serverAddress[1])), serverInfo + url = 'http://www.panda.tv/ajax_chatinfo?roomid=%s&_=%s'%(roomId, str(int(time.time()))) + roomInfo = requests.get(url).json()['data'] + serverAddress = roomInfo['chat_addr_list'][0].split(':') + return (serverAddress[0], int(serverAddress[1])), roomInfo def _init_socket(self, danmu, roomInfo): data = [ ('u', '%s@%s'%(roomInfo['rid'], roomInfo['appid'])), diff --git a/run.py b/run.py index 817ff3d..64a1266 100644 --- a/run.py +++ b/run.py @@ -6,7 +6,7 @@ def pp(msg): print(msg.encode(sys.stdin.encoding, 'ignore'). decode(sys.stdin.encoding)) -dmc = DanMuClient('https://www.douyu.com/32892') +dmc = DanMuClient('https://www.panda.tv/20641') if not dmc.isValid(): print('Url not valid') @dmc.danmu