From: Jaime Marquínez Ferrándiz Date: Sat, 8 Mar 2014 19:06:20 +0000 (+0100) Subject: [spike] Add support for downloading the mobile version if the normal version is geobl... X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=340b046876f0b188527be169b4b1c7141e6ed8aa;p=youtube-dl.git [spike] Add support for downloading the mobile version if the normal version is geoblocked --- diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py index 3a33cc9b6..652054b63 100644 --- a/youtube_dl/extractor/mtv.py +++ b/youtube_dl/extractor/mtv.py @@ -5,9 +5,11 @@ import re from .common import InfoExtractor from ..utils import ( compat_urllib_parse, + compat_urllib_request, ExtractorError, find_xpath_attr, fix_xml_ampersands, + unescapeHTML, url_basename, RegexNotFoundError, ) @@ -18,6 +20,7 @@ def _media_xml_tag(tag): class MTVServicesInfoExtractor(InfoExtractor): + _MOBILE_TEMPLATE = None @staticmethod def _id_from_uri(uri): return uri.split(':')[-1] @@ -39,8 +42,22 @@ class MTVServicesInfoExtractor(InfoExtractor): else: return thumb_node.attrib['url'] - def _extract_video_formats(self, mdoc): + def _extract_mobile_video_formats(self, mtvn_id): + webpage_url = self._MOBILE_TEMPLATE % mtvn_id + req = compat_urllib_request.Request(webpage_url) + # Otherwise we get a webpage that would execute some javascript + req.add_header('Youtubedl-user-agent', 'curl/7') + webpage = self._download_webpage(req, mtvn_id, + 'Downloading mobile page') + url = unescapeHTML(self._search_regex(r'