[extractor/common] Recognize Indian censorship (#5021)
authorPhilipp Hagemeister <phihag@phihag.de>
Sat, 21 Feb 2015 13:51:07 +0000 (14:51 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Sat, 21 Feb 2015 13:51:07 +0000 (14:51 +0100)
youtube_dl/extractor/common.py

index 08b8ad37c45ae1aa1528274071a250cfd3f27e89..ee64ad329da7775c9192b354f7d8916610ebc00c 100644 (file)
@@ -391,6 +391,16 @@ class InfoExtractor(object):
             if blocked_iframe:
                 msg += ' Visit %s for more details' % blocked_iframe
             raise ExtractorError(msg, expected=True)
+        if '<title>The URL you requested has been blocked</title>' in content[:512]:
+            msg = (
+                'Access to this webpage has been blocked by Indian censorship. '
+                'Use a VPN or proxy server (with --proxy) to route around it.')
+            block_msg = self._html_search_regex(
+                r'</h1><p>(.*?)</p>',
+                content, 'block message', default=None)
+            if block_msg:
+                msg += ' (Message: "%s")' % block_msg.replace('\n', ' ')
+            raise ExtractorError(msg, expected=True)
 
         return content