From 38e3b4618f27cce834dc4225907854a53d391d80 Mon Sep 17 00:00:00 2001 From: MaxwellGoblin Date: Sun, 6 Aug 2017 02:08:20 +0800 Subject: [PATCH] [panda]quit if cannot found room id from url --- src/you_get/extractors/panda.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/you_get/extractors/panda.py b/src/you_get/extractors/panda.py index 45249bd2..ba6f2b4e 100644 --- a/src/you_get/extractors/panda.py +++ b/src/you_get/extractors/panda.py @@ -3,11 +3,15 @@ __all__ = ['panda_download'] from ..common import * +from ..util.log import * import json import time def panda_download(url, output_dir = '.', merge = True, info_only = False, **kwargs): - roomid = url[url.rfind('/')+1:] + roomid = re.search('/(\d+)', url) + if roomid is None: + log.wtf('Cannot found room id for this url') + roomid = roomid.group(1) json_request_url ="http://www.panda.tv/api_room_v2?roomid={}&__plat=pc_web&_={}".format(roomid, int(time.time())) content = get_html(json_request_url) api_json = json.loads(content)