Parcourir la source

[xvideos] Capture and output inline error if any

Sergey M․ il y a 11 ans
Parent
commit
3217377b3c
1 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. 6 0
      youtube_dl/extractor/xvideos.py

+ 6 - 0
youtube_dl/extractor/xvideos.py

@@ -5,6 +5,8 @@ import re
 from .common import InfoExtractor
 from .common import InfoExtractor
 from ..utils import (
 from ..utils import (
     compat_urllib_parse,
     compat_urllib_parse,
+    ExtractorError,
+    clean_html,
 )
 )
 
 
 
 
@@ -28,6 +30,10 @@ class XVideosIE(InfoExtractor):
 
 
         self.report_extraction(video_id)
         self.report_extraction(video_id)
 
 
+        mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage)
+        if mobj:
+            raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)
+
         # Extract video URL
         # Extract video URL
         video_url = compat_urllib_parse.unquote(
         video_url = compat_urllib_parse.unquote(
             self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
             self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))