aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/youtube.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-07-31 10:45:13 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-07-31 10:45:13 +0200
commit75952c6e3dcbab1b7c239b02272ca1bb5336f72d (patch)
treed72316c9af7342a1320fe33e575edd920590db2d /youtube_dl/extractor/youtube.py
parent05afc96b73cc4975aef6ace912566a2b36141cc4 (diff)
YoutubeIE: new algo for length 86 (fixes #1156)
Now is using the same length as the flash player used for age protected videos, but the algorithm is different, so now for age protected videos it first tries to use the old algo.
Diffstat (limited to 'youtube_dl/extractor/youtube.py')
-rw-r--r--youtube_dl/extractor/youtube.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index f10f2e3dd..ba8fdfdf2 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -286,7 +286,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
elif len(s) == 87:
return s[4:23] + s[86] + s[24:85]
elif len(s) == 86:
- return s[2:63] + s[82] + s[64:82] + s[63]
+ return s[83:85] + s[26] + s[79:46:-1] + s[85] + s[45:36:-1] + s[30] + s[35:30:-1] + s[46] + s[29:26:-1] + s[82] + s[25:1:-1]
elif len(s) == 85:
return s[2:8] + s[0] + s[9:21] + s[65] + s[22:65] + s[84] + s[66:82] + s[21]
elif len(s) == 84:
@@ -303,6 +303,16 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
else:
raise ExtractorError(u'Unable to decrypt signature, key length %d not supported; retrying might work' % (len(s)))
+ def _decrypt_signature_age_gate(self, s):
+ # The videos with age protection use another player, so the algorithms
+ # can be different.
+ if len(s) == 86:
+ return s[2:63] + s[82] + s[64:82] + s[63]
+ else:
+ # Fallback to the other algortihms
+ self._decrypt_signature(s)
+
+
def _get_available_subtitles(self, video_id):
self.report_video_subtitles_download(video_id)
request = compat_urllib_request.Request('http://video.google.com/timedtext?hl=en&type=list&v=%s' % video_id)
@@ -611,7 +621,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
parts_sizes = u'.'.join(compat_str(len(part)) for part in s.split('.'))
self.to_screen(u'encrypted signature length %d (%s), itag %s, %s' %
(len(s), parts_sizes, url_data['itag'][0], player))
- signature = self._decrypt_signature(url_data['s'][0])
+ encrypted_sig = url_data['s'][0]
+ if age_gate:
+ signature = self._decrypt_signature_age_gate(encrypted_sig)
+ else:
+ signature = self._decrypt_signature(encrypted_sig)
url += '&signature=' + signature
if 'ratebypass' not in url:
url += '&ratebypass=yes'