From 63a562f95ee62e05e689bf7fbf8e923749248b05 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Thu, 26 Feb 2015 09:19:26 +0100 Subject: [PATCH] [escapist] Detect IP blocking and use another UA (Fixes #5069) --- youtube_dl/extractor/escapist.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/escapist.py b/youtube_dl/extractor/escapist.py index b45c1dbd0..80e9084f4 100644 --- a/youtube_dl/extractor/escapist.py +++ b/youtube_dl/extractor/escapist.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_urllib_parse, + compat_urllib_request, ) from ..utils import ( ExtractorError, @@ -12,6 +13,7 @@ from ..utils import ( class EscapistIE(InfoExtractor): _VALID_URL = r'https?://?(www\.)?escapistmagazine\.com/videos/view/[^/?#]+/(?P[0-9]+)-[^/?#]*(?:$|[?#])' + _USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko' _TEST = { 'url': 'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate', 'md5': 'ab3a706c681efca53f0a35f1415cf0d1', @@ -28,7 +30,9 @@ class EscapistIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - webpage = self._download_webpage(url, video_id) + webpage_req = compat_urllib_request.Request(url) + webpage_req.add_header('User-Agent', self._USER_AGENT) + webpage = self._download_webpage(webpage_req, video_id) uploader_id = self._html_search_regex( r"\s*