瀏覽代碼

[youtube] Capture and output login error message

Sergey M․ 9 年之前
父節點
當前提交
494ab6db73
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      youtube_dl/extractor/youtube.py

+ 6 - 0
youtube_dl/extractor/youtube.py

@@ -125,6 +125,12 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
         if login_results is False:
             return False
 
+        error_msg = self._html_search_regex(
+            r'<[^>]+id="errormsg_0_Passwd"[^>]*>([^<]+)<',
+            login_results, 'error message', default=None)
+        if error_msg:
+            raise ExtractorError('Unable to login: %s' % error_msg, expected=True)
+
         if re.search(r'id="errormsg_0_Passwd"', login_results) is not None:
             raise ExtractorError('Please use your account password and a two-factor code instead of an application-specific password.', expected=True)