diff --git a/src/you_get/extractors/panda.py b/src/you_get/extractors/panda.py index d6208002..fb2ee0c3 100644 --- a/src/you_get/extractors/panda.py +++ b/src/you_get/extractors/panda.py @@ -5,6 +5,7 @@ __all__ = ['panda_download'] from ..common import * import json import time +import requests def panda_download(url, output_dir = '.', merge = True, info_only = False, **kwargs): roomid = url[url.rfind('/')+1:] @@ -20,13 +21,16 @@ def panda_download(url, output_dir = '.', merge = True, info_only = False, **kwa room_key = data.get('videoinfo')['room_key'] plflag = data.get('videoinfo')['plflag'].split('_') status = data.get('videoinfo')['status'] - if data.get("roominfo")["banned_reason"]: - data2 = json.loads(data['videoinfo']['plflag_list']) - plflag = data2["backup"][0].split('_') if status is not "2": raise ValueError("The live stream is not online! (status:%s)" % status) real_url = 'http://pl{}.live.panda.tv/live_panda/{}.flv'.format(plflag[1],room_key) - + counter = 0 + while (requests.head(real_url, allow_redirects=True).status_code == 403): + data2 = json.loads(data['videoinfo']['plflag_list']) + plflag = data2["backup"][counter].split('_') + counter = counter + 1 + real_url = 'http://pl{}.live.panda.tv/live_panda/{}.flv'.format(plflag[1],room_key) + print_info(site_info, title, 'flv', float('inf')) if not info_only: download_urls([real_url], title, 'flv', None, output_dir, merge = merge)