diff --git a/src/you_get/extractors/panda.py b/src/you_get/extractors/panda.py index 90bbfc55..999cb7c6 100644 --- a/src/you_get/extractors/panda.py +++ b/src/you_get/extractors/panda.py @@ -5,7 +5,9 @@ __all__ = ['panda_download'] from ..common import * import json import time -import requests +import urllib.request +import urllib.error + def panda_download(url, output_dir = '.', merge = True, info_only = False, **kwargs): roomid = url[url.rfind('/')+1:] @@ -26,10 +28,22 @@ def panda_download(url, output_dir = '.', merge = True, info_only = False, **kwa real_url = 'http://pl{}.live.panda.tv/live_panda/{}.flv'.format(plflag[1],room_key) counter = 0 data2 = json.loads(data['videoinfo']['plflag_list']) - while (requests.head(real_url, allow_redirects=True).status_code == 403 and counter < len(data2["backup"])): + pl_code_error = False + try: + urllib.request.urlopen(real_url) + except urllib.error.HTTPError as e: + pl_code_error = True + + while (pl_code_error and counter < len(data2["backup"])): plflag = data2["backup"][counter].split('_') counter = counter + 1 real_url = 'http://pl{}.live.panda.tv/live_panda/{}.flv'.format(plflag[1],room_key) + try: + urllib.request.urlopen(real_url) + except urllib.error.HTTPError as e: + pl_code_error = True + else: + pl_code_error = False print_info(site_info, title, 'flv', float('inf')) if not info_only: