浏览代码

[dailymotion] Raise GeoRestrictedError

Sergey M․ 8 年之前
父节点
当前提交
8878789f11
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      youtube_dl/extractor/dailymotion.py

+ 6 - 1
youtube_dl/extractor/dailymotion.py

@@ -282,9 +282,14 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
         }
 
     def _check_error(self, info):
+        error = info.get('error')
         if info.get('error') is not None:
+            title = error['title']
+            # See https://developer.dailymotion.com/api#access-error
+            if error.get('code') == 'DM007':
+                self.raise_geo_restricted(msg=title)
             raise ExtractorError(
-                '%s said: %s' % (self.IE_NAME, info['error']['title']), expected=True)
+                '%s said: %s' % (self.IE_NAME, title), expected=True)
 
     def _get_subtitles(self, video_id, webpage):
         try: