[youtube] Use a static algorithm for the age gate videos' signatures (fixes #3270)

This commit is contained in:
Jaime Marquínez Ferrándiz 2014-07-16 12:37:41 +02:00
parent ee90ddab94
commit 1b262962c5

View File

@ -865,6 +865,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
def _decrypt_signature(self, s, video_id, player_url, age_gate=False):
"""Turn the encrypted s field into a working signature"""
if age_gate:
return self._static_decrypt_age_gate_signature(s)
if player_url is None:
raise ExtractorError(u'Cannot decrypt signature without player_url')
@ -886,6 +889,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
raise ExtractorError(
u'Automatic signature extraction failed: ' + tb, cause=e)
def _static_decrypt_age_gate_signature(self, s):
if len(s) == 86:
return s[2:63] + s[82] + s[64:82] + s[63]
else:
raise ExtractorError(u'Unable to decrypt signature, key length %d not supported; retrying might work' % (len(s)))
def _get_available_subtitles(self, video_id, webpage):
try:
sub_list = self._download_webpage(