浏览代码

[youtube] More useful messages for georestricted videos (#5716)

Yen Chi Hsuan 10 年之前
父节点
当前提交
af214c3a79
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      youtube_dl/extractor/youtube.py

+ 7 - 0
youtube_dl/extractor/youtube.py

@@ -32,6 +32,7 @@ from ..utils import (
     unescapeHTML,
     unescapeHTML,
     unified_strdate,
     unified_strdate,
     uppercase_escape,
     uppercase_escape,
+    ISO3166Utils,
 )
 )
 
 
 
 
@@ -903,6 +904,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
                         break
                         break
         if 'token' not in video_info:
         if 'token' not in video_info:
             if 'reason' in video_info:
             if 'reason' in video_info:
+                if 'The uploader has not made this video available in your country.' in video_info['reason']:
+                    regions_allowed = self._html_search_meta('regionsAllowed', video_webpage, default=None)
+                    if regions_allowed is not None:
+                        raise ExtractorError('YouTube said: This video is available in %s only' % (
+                            ', '.join(map(ISO3166Utils.short2full, regions_allowed.split(',')))),
+                            expected=True)
                 raise ExtractorError(
                 raise ExtractorError(
                     'YouTube said: %s' % video_info['reason'][0],
                     'YouTube said: %s' % video_info['reason'][0],
                     expected=True, video_id=video_id)
                     expected=True, video_id=video_id)