1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 19:52:11 +00:00

[youtube] Show format ID in signature deobfuscation -v output

This commit is contained in:
Philipp Hagemeister 2014-08-02 06:35:18 +02:00
parent 9afa6ede21
commit 201e9eaa0e

View file

@ -806,51 +806,54 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
url_map = {} url_map = {}
for url_data_str in encoded_url_map.split(','): for url_data_str in encoded_url_map.split(','):
url_data = compat_parse_qs(url_data_str) url_data = compat_parse_qs(url_data_str)
if 'itag' in url_data and 'url' in url_data: if 'itag' not in url_data or 'url' not in url_data:
url = url_data['url'][0] continue
if 'sig' in url_data: format_id = url_data['itag'][0]
url += '&signature=' + url_data['sig'][0] url = url_data['url'][0]
elif 's' in url_data:
encrypted_sig = url_data['s'][0]
if not age_gate: if 'sig' in url_data:
jsplayer_url_json = self._search_regex( url += '&signature=' + url_data['sig'][0]
r'"assets":.+?"js":\s*("[^"]+")', elif 's' in url_data:
video_webpage, u'JS player URL') encrypted_sig = url_data['s'][0]
player_url = json.loads(jsplayer_url_json)
if not age_gate:
jsplayer_url_json = self._search_regex(
r'"assets":.+?"js":\s*("[^"]+")',
video_webpage, u'JS player URL')
player_url = json.loads(jsplayer_url_json)
if player_url is None:
player_url_json = self._search_regex(
r'ytplayer\.config.*?"url"\s*:\s*("[^"]+")',
video_webpage, u'age gate player URL')
player_url = json.loads(player_url_json)
if self._downloader.params.get('verbose'):
if player_url is None: if player_url is None:
player_url_json = self._search_regex( player_version = 'unknown'
r'ytplayer\.config.*?"url"\s*:\s*("[^"]+")', player_desc = 'unknown'
video_webpage, u'age gate player URL') else:
player_url = json.loads(player_url_json) if player_url.endswith('swf'):
player_version = self._search_regex(
if self._downloader.params.get('verbose'): r'-(.+?)(?:/watch_as3)?\.swf$', player_url,
if player_url is None: u'flash player', fatal=False)
player_version = 'unknown' player_desc = 'flash player %s' % player_version
player_desc = 'unknown'
else: else:
if player_url.endswith('swf'): player_version = self._search_regex(
player_version = self._search_regex( r'html5player-([^/]+?)(?:/html5player)?\.js',
r'-(.+?)(?:/watch_as3)?\.swf$', player_url, player_url,
u'flash player', fatal=False) 'html5 player', fatal=False)
player_desc = 'flash player %s' % player_version player_desc = u'html5 player %s' % player_version
else:
player_version = self._search_regex(
r'html5player-([^/]+?)(?:/html5player)?\.js',
player_url,
'html5 player', fatal=False)
player_desc = u'html5 player %s' % player_version
parts_sizes = u'.'.join(compat_str(len(part)) for part in encrypted_sig.split('.')) parts_sizes = u'.'.join(compat_str(len(part)) for part in encrypted_sig.split('.'))
self.to_screen(u'encrypted signature length %d (%s), itag %s, %s' % self.to_screen(u'{%s} encrypted signature length %d (%s), itag %s, %s' %
(len(encrypted_sig), parts_sizes, url_data['itag'][0], player_desc)) (format_id, len(encrypted_sig), parts_sizes, url_data['itag'][0], player_desc))
signature = self._decrypt_signature( signature = self._decrypt_signature(
encrypted_sig, video_id, player_url, age_gate) encrypted_sig, video_id, player_url, age_gate)
url += '&signature=' + signature url += '&signature=' + signature
if 'ratebypass' not in url: if 'ratebypass' not in url:
url += '&ratebypass=yes' url += '&ratebypass=yes'
url_map[url_data['itag'][0]] = url url_map[format_id] = url
formats = _map_to_format_list(url_map) formats = _map_to_format_list(url_map)
elif video_info.get('hlsvp'): elif video_info.get('hlsvp'):
manifest_url = video_info['hlsvp'][0] manifest_url = video_info['hlsvp'][0]