[youtube] Modernize

This commit is contained in:
Sergey M․ 2017-05-21 01:18:56 +07:00
parent fdc20f87a6
commit dc4e4f90a2
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D
1 changed files with 19 additions and 8 deletions

View File

@ -1435,7 +1435,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
else: else:
age_gate = False age_gate = False
video_info = None video_info = None
sts = '' sts = None
# Try looking directly into the video webpage # Try looking directly into the video webpage
ytplayer_config = self._get_ytplayer_config(video_id, video_webpage) ytplayer_config = self._get_ytplayer_config(video_id, video_webpage)
if ytplayer_config: if ytplayer_config:
@ -1452,7 +1452,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
args['ypc_vid'], YoutubeIE.ie_key(), video_id=args['ypc_vid']) args['ypc_vid'], YoutubeIE.ie_key(), video_id=args['ypc_vid'])
if args.get('livestream') == '1' or args.get('live_playback') == 1: if args.get('livestream') == '1' or args.get('live_playback') == 1:
is_live = True is_live = True
sts = ytplayer_config.get('sts', '') sts = ytplayer_config.get('sts')
if not video_info or self._downloader.params.get('youtube_include_dash_manifest', True): if not video_info or self._downloader.params.get('youtube_include_dash_manifest', True):
# We also try looking in get_video_info since it may contain different dashmpd # We also try looking in get_video_info since it may contain different dashmpd
# URL that points to a DASH manifest with possibly different itag set (some itags # URL that points to a DASH manifest with possibly different itag set (some itags
@ -1461,14 +1461,25 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
# The general idea is to take a union of itags of both DASH manifests (for example # The general idea is to take a union of itags of both DASH manifests (for example
# video with such 'manifest behavior' see https://github.com/rg3/youtube-dl/issues/6093) # video with such 'manifest behavior' see https://github.com/rg3/youtube-dl/issues/6093)
self.report_video_info_webpage_download(video_id) self.report_video_info_webpage_download(video_id)
for el_type in ['&el=info', '&el=embedded', '&el=detailpage', '&el=vevo', '']: for el in ('info', 'embedded', 'detailpage', 'vevo', ''):
video_info_url = ( query = {
'%s://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en&sts=%s' 'video_id': video_id,
% (proto, video_id, el_type, sts)) 'ps': 'default',
'eurl': '',
'gl': 'US',
'hl': 'en',
}
if el:
query['el'] = el
if sts:
query['sts'] = sts
video_info_webpage = self._download_webpage( video_info_webpage = self._download_webpage(
video_info_url, '%s://www.youtube.com/get_video_info' % proto,
video_id, note=False, video_id, note=False,
errnote='unable to download video info webpage') errnote='unable to download video info webpage',
fatal=False, query=query)
if not video_info_webpage:
continue
get_video_info = compat_parse_qs(video_info_webpage) get_video_info = compat_parse_qs(video_info_webpage)
if get_video_info.get('use_cipher_signature') != ['True']: if get_video_info.get('use_cipher_signature') != ['True']:
add_dash_mpd(get_video_info) add_dash_mpd(get_video_info)