mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 20:52:31 +03:00
Rewrote it to not use requests
This commit is contained in:
parent
4920a159d8
commit
dc6b96f5f6
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user