|
|
|
@ -547,6 +547,34 @@ class InfoExtractor(object):
|
|
|
|
|
|
|
|
|
|
return encoding
|
|
|
|
|
|
|
|
|
|
def __check_blocked(self, content):
|
|
|
|
|
first_block = content[:512]
|
|
|
|
|
if ('<title>Access to this site is blocked</title>' in content and
|
|
|
|
|
'Websense' in first_block):
|
|
|
|
|
msg = 'Access to this webpage has been blocked by Websense filtering software in your network.'
|
|
|
|
|
blocked_iframe = self._html_search_regex(
|
|
|
|
|
r'<iframe src="([^"]+)"', content,
|
|
|
|
|
'Websense information URL', default=None)
|
|
|
|
|
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 first_block:
|
|
|
|
|
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)
|
|
|
|
|
if ('<title>TTK :: Доступ к ресурсу ограничен</title>' in content and
|
|
|
|
|
'blocklist.rkn.gov.ru' in content):
|
|
|
|
|
raise ExtractorError(
|
|
|
|
|
'Access to this webpage has been blocked by decision of the Russian government. '
|
|
|
|
|
'Visit http://blocklist.rkn.gov.ru/ for a block reason.',
|
|
|
|
|
expected=True)
|
|
|
|
|
|
|
|
|
|
def _webpage_read_content(self, urlh, url_or_request, video_id, note=None, errnote=None, fatal=True, prefix=None, encoding=None):
|
|
|
|
|
content_type = urlh.headers.get('Content-Type', '')
|
|
|
|
|
webpage_bytes = urlh.read()
|
|
|
|
@ -588,25 +616,7 @@ class InfoExtractor(object):
|
|
|
|
|
except LookupError:
|
|
|
|
|
content = webpage_bytes.decode('utf-8', 'replace')
|
|
|
|
|
|
|
|
|
|
if ('<title>Access to this site is blocked</title>' in content and
|
|
|
|
|
'Websense' in content[:512]):
|
|
|
|
|
msg = 'Access to this webpage has been blocked by Websense filtering software in your network.'
|
|
|
|
|
blocked_iframe = self._html_search_regex(
|
|
|
|
|
r'<iframe src="([^"]+)"', content,
|
|
|
|
|
'Websense information URL', default=None)
|
|
|
|
|
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)
|
|
|
|
|
self.__check_blocked(content)
|
|
|
|
|
|
|
|
|
|
return content
|
|
|
|
|
|
|
|
|
|