|
|
|
@ -1500,7 +1500,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|
|
|
|
return lambda s: jsi.extract_function_from_code(*func_code)([s])
|
|
|
|
|
|
|
|
|
|
def _n_descramble(self, n_param, player_url, video_id):
|
|
|
|
|
"""Compute the response to YT's "n" parameter challenge
|
|
|
|
|
"""Compute the response to YT's "n" parameter challenge,
|
|
|
|
|
or None
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
n_param -- challenge string that is the value of the
|
|
|
|
@ -1518,7 +1519,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|
|
|
|
if player_id not in self._player_cache:
|
|
|
|
|
self._player_cache[player_id] = self._extract_n_function(video_id, player_url)
|
|
|
|
|
func = self._player_cache[player_id]
|
|
|
|
|
self._player_cache[sig_id] = func(n_param)
|
|
|
|
|
ret = func(n_param)
|
|
|
|
|
if ret.startswith('enhanced_except_'):
|
|
|
|
|
raise ExtractorError('Unhandled exception in decode')
|
|
|
|
|
self._player_cache[sig_id] = ret
|
|
|
|
|
if self._downloader.params.get('verbose', False):
|
|
|
|
|
self._downloader.to_screen('[debug] [%s] %s' % (self.IE_NAME, 'Decrypted nsig {0} => {1}'.format(n_param, self._player_cache[sig_id])))
|
|
|
|
|
return self._player_cache[sig_id]
|
|
|
|
@ -1539,7 +1543,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|
|
|
|
continue
|
|
|
|
|
n_param = n_param[-1]
|
|
|
|
|
n_response = self._n_descramble(n_param, player_url, video_id)
|
|
|
|
|
if n_response:
|
|
|
|
|
if n_response is None:
|
|
|
|
|
# give up if descrambling failed
|
|
|
|
|
break
|
|
|
|
|
qs['n'] = [n_response]
|
|
|
|
|
fmt['url'] = compat_urlparse.urlunparse(
|
|
|
|
|
parsed_fmt_url._replace(query=compat_urllib_parse_urlencode(qs, True)))
|
|
|
|
|