summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPhilipp Hagemeister <[email protected]>2014-07-11 10:44:39 +0200
committerPhilipp Hagemeister <[email protected]>2014-07-11 10:44:39 +0200
commitc8bf86d50d65ac434c7d683c21ec4d362f0cf030 (patch)
tree3492d5f55a7b12f465f7af6e40d4069ed933e9a5
parent61989fb5e9613b042c7f72d06e141242d60a1fde (diff)
downloadyoutube-dl-c8bf86d50d65ac434c7d683c21ec4d362f0cf030.tar.gz
youtube-dl-c8bf86d50d65ac434c7d683c21ec4d362f0cf030.zip
[youtube] Correct signature extraction error detection
-rw-r--r--youtube_dl/extractor/youtube.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 15208f47f..6123e1256 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -865,27 +865,26 @@ 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 player_url is not None:
- if player_url.startswith(u'//'):
- player_url = u'https:' + player_url
- try:
- player_id = (player_url, len(s))
- if player_id not in self._player_cache:
- func = self._extract_signature_function(
- video_id, player_url, len(s)
- )
- self._player_cache[player_id] = func
- func = self._player_cache[player_id]
- if self._downloader.params.get('youtube_print_sig_code'):
- self._print_sig_code(func, len(s))
- return func(s)
- except Exception as e:
- tb = traceback.format_exc()
- raise ExtractorError(
- u'Automatic signature extraction failed: ' + tb, cause=e)
+ if player_url is None:
+ raise ExtractorError(u'Cannot decrypt signature without player_url')
- return self._static_decrypt_signature(
- s, video_id, player_url, age_gate)
+ if player_url.startswith(u'//'):
+ player_url = u'https:' + player_url
+ try:
+ player_id = (player_url, len(s))
+ if player_id not in self._player_cache:
+ func = self._extract_signature_function(
+ video_id, player_url, len(s)
+ )
+ self._player_cache[player_id] = func
+ func = self._player_cache[player_id]
+ if self._downloader.params.get('youtube_print_sig_code'):
+ self._print_sig_code(func, len(s))
+ return func(s)
+ except Exception as e:
+ tb = traceback.format_exc()
+ raise ExtractorError(
+ u'Automatic signature extraction failed: ' + tb, cause=e)
def _get_available_subtitles(self, video_id, webpage):
try: