mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 00:33:58 +03:00
[youku] fix #771
This commit is contained in:
parent
b6d4360491
commit
c0b856a160
@ -11,13 +11,17 @@ import traceback
|
|||||||
class Youku(VideoExtractor):
|
class Youku(VideoExtractor):
|
||||||
name = "优酷 (Youku)"
|
name = "优酷 (Youku)"
|
||||||
|
|
||||||
|
# Last updated: 2015-11-24
|
||||||
stream_types = [
|
stream_types = [
|
||||||
{'id': 'hd3', 'container': 'flv', 'video_profile': '1080P'},
|
{'id': 'mp4hd3', 'alias-of' : 'hd3'},
|
||||||
{'id': 'hd2', 'container': 'flv', 'video_profile': '超清'},
|
{'id': 'hd3', 'container': 'flv', 'video_profile': '1080P'},
|
||||||
{'id': 'mp4', 'container': 'mp4', 'video_profile': '高清'},
|
{'id': 'mp4hd2', 'alias-of' : 'hd2'},
|
||||||
{'id': 'flvhd', 'container': 'flv', 'video_profile': '高清'},
|
{'id': 'hd2', 'container': 'flv', 'video_profile': '超清'},
|
||||||
{'id': 'flv', 'container': 'flv', 'video_profile': '标清'},
|
{'id': 'mp4hd', 'alias-of' : 'mp4'},
|
||||||
{'id': '3gphd', 'container': '3gp', 'video_profile': '高清(3GP)'},
|
{'id': 'mp4', 'container': 'mp4', 'video_profile': '高清'},
|
||||||
|
{'id': 'flvhd', 'container': 'flv', 'video_profile': '标清'},
|
||||||
|
{'id': 'flv', 'container': 'flv', 'video_profile': '标清'},
|
||||||
|
{'id': '3gphd', 'container': '3gp', 'video_profile': '标清(3GP)'},
|
||||||
]
|
]
|
||||||
|
|
||||||
def generate_ep(vid, ep):
|
def generate_ep(vid, ep):
|
||||||
@ -107,40 +111,30 @@ class Youku(VideoExtractor):
|
|||||||
self.download_playlist_by_url(self.url, **kwargs)
|
self.download_playlist_by_url(self.url, **kwargs)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
meta = json.loads(get_html('http://v.youku.com/player/getPlayList/VideoIDS/%s/Pf/4/ctype/12/ev/1' % self.vid))
|
api_url = 'http://play.youku.com/play/get.json?vid=%s&ct=12' % self.vid
|
||||||
if not meta['data']:
|
try:
|
||||||
|
meta = json.loads(get_html(api_url))
|
||||||
|
data = meta['data']
|
||||||
|
except:
|
||||||
log.wtf('[Failed] Video not found.')
|
log.wtf('[Failed] Video not found.')
|
||||||
metadata0 = meta['data'][0]
|
# TBD: error code? password protected?
|
||||||
|
|
||||||
if 'error_code' in metadata0 and metadata0['error_code']:
|
self.title = data['video']['title']
|
||||||
if metadata0['error_code'] == -8:
|
self.ep = data['security']['encrypt_string']
|
||||||
log.w('[Warning] This video can only be streamed within Mainland China!')
|
self.ip = data['security']['ip']
|
||||||
log.w('Use \'-y\' to specify a proxy server for extracting stream data.\n')
|
|
||||||
elif metadata0['error_code'] == -6:
|
|
||||||
log.w('[Warning] This video is password protected.')
|
|
||||||
self.password_protected = True
|
|
||||||
|
|
||||||
self.title = metadata0['title']
|
stream_types = dict([(i['id'], i) for i in self.stream_types])
|
||||||
|
for stream in data['stream']:
|
||||||
self.ep = metadata0['ep']
|
stream_id = stream['stream_type']
|
||||||
self.ip = metadata0['ip']
|
if stream_id in stream_types:
|
||||||
|
if 'alias-of' in stream_types[stream_id]:
|
||||||
if 'dvd' in metadata0 and 'audiolang' in metadata0['dvd']:
|
stream_id = stream_types[stream_id]['alias-of']
|
||||||
self.audiolang = metadata0['dvd']['audiolang']
|
self.streams[stream_id] = {
|
||||||
for i in self.audiolang:
|
'container': stream_types[stream_id]['container'],
|
||||||
i['url'] = 'http://v.youku.com/v_show/id_{}'.format(i['vid'])
|
'video_profile': stream_types[stream_id]['video_profile'],
|
||||||
|
'size': stream['size']
|
||||||
for stream_type in self.stream_types:
|
}
|
||||||
if stream_type['id'] in metadata0['streamsizes']:
|
# TBD: self.audio_lang['url']
|
||||||
stream_id = stream_type['id']
|
|
||||||
stream_size = int(metadata0['streamsizes'][stream_id])
|
|
||||||
self.streams[stream_id] = {'container': stream_type['container'], 'video_profile': stream_type['video_profile'], 'size': stream_size}
|
|
||||||
|
|
||||||
if not self.streams:
|
|
||||||
for stream_type in self.stream_types:
|
|
||||||
if stream_type['id'] in metadata0['streamtypes_o']:
|
|
||||||
stream_id = stream_type['id']
|
|
||||||
self.streams[stream_id] = {'container': stream_type['container'], 'video_profile': stream_type['video_profile']}
|
|
||||||
|
|
||||||
def extract(self, **kwargs):
|
def extract(self, **kwargs):
|
||||||
if 'stream_id' in kwargs and kwargs['stream_id']:
|
if 'stream_id' in kwargs and kwargs['stream_id']:
|
||||||
|
Loading…
Reference in New Issue
Block a user