mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 20:52:31 +03:00
fallback to ct=12 request if encounter HTTP Error 404
This commit is contained in:
parent
405ffc0633
commit
eb3b3b61f5
@ -92,7 +92,7 @@ import platform
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from urllib import request, parse
|
from urllib import request, parse, error
|
||||||
from http import cookiejar
|
from http import cookiejar
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
|
@ -143,6 +143,9 @@ class Youku(VideoExtractor):
|
|||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
api_url = 'http://play.youku.com/play/get.json?vid=%s&ct=12' % self.vid
|
api_url = 'http://play.youku.com/play/get.json?vid=%s&ct=12' % self.vid
|
||||||
|
if hasattr(self, "err_code") and self.err_code == 404:
|
||||||
|
api_url1 = api_url
|
||||||
|
else:
|
||||||
api_url1 = 'http://play.youku.com/play/get.json?vid=%s&ct=10' % self.vid
|
api_url1 = 'http://play.youku.com/play/get.json?vid=%s&ct=10' % self.vid
|
||||||
try:
|
try:
|
||||||
meta = json.loads(get_content(
|
meta = json.loads(get_content(
|
||||||
@ -188,6 +191,7 @@ class Youku(VideoExtractor):
|
|||||||
|
|
||||||
stream_types = dict([(i['id'], i) for i in self.stream_types])
|
stream_types = dict([(i['id'], i) for i in self.stream_types])
|
||||||
self.streams_parameter = {}
|
self.streams_parameter = {}
|
||||||
|
self.streams = {}
|
||||||
audio_lang = data1['stream'][0]['audio_lang']
|
audio_lang = data1['stream'][0]['audio_lang']
|
||||||
for stream in data1['stream']:
|
for stream in data1['stream']:
|
||||||
stream_id = stream['stream_type']
|
stream_id = stream['stream_type']
|
||||||
@ -254,7 +258,29 @@ class Youku(VideoExtractor):
|
|||||||
fileid = fileid,
|
fileid = fileid,
|
||||||
q = q
|
q = q
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
ksegs += [i['server'] for i in json.loads(get_content(u))]
|
ksegs += [i['server'] for i in json.loads(get_content(u))]
|
||||||
|
except error.HTTPError as err:
|
||||||
|
if err.code == 404:
|
||||||
|
self.err_code = 404
|
||||||
|
#copy from extractor.download_by_vid
|
||||||
|
if 'extractor_proxy' in kwargs and kwargs['extractor_proxy']:
|
||||||
|
set_proxy(parse_host(kwargs['extractor_proxy']))
|
||||||
|
self.prepare(**kwargs)
|
||||||
|
if 'extractor_proxy' in kwargs and kwargs['extractor_proxy']:
|
||||||
|
unset_proxy()
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.streams_sorted = [dict([('id', stream_type['id'])] + list(self.streams[stream_type['id']].items())) for stream_type in self.__class__.stream_types if stream_type['id'] in self.streams]
|
||||||
|
except:
|
||||||
|
self.streams_sorted = [dict([('itag', stream_type['itag'])] + list(self.streams[stream_type['itag']].items())) for stream_type in self.__class__.stream_types if stream_type['itag'] in self.streams]
|
||||||
|
|
||||||
|
self.extract(**kwargs)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
||||||
if not kwargs['info_only']:
|
if not kwargs['info_only']:
|
||||||
self.streams[stream_id]['src'] = ksegs
|
self.streams[stream_id]['src'] = ksegs
|
||||||
|
Loading…
Reference in New Issue
Block a user