X-Git-Url: https://git.rapsys.eu/youtubedl/blobdiff_plain/af478477605bdf3f5d57562035885cfee905f379..509eeaaa67b2f901752c50fc6edf41954dbe3085:/youtube_dl/extractor/mtv.py diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py index 5447b6c..e5ca41b 100644 --- a/youtube_dl/extractor/mtv.py +++ b/youtube_dl/extractor/mtv.py @@ -5,9 +5,12 @@ import re from .common import InfoExtractor from ..utils import ( compat_urllib_parse, + compat_urllib_request, ExtractorError, find_xpath_attr, fix_xml_ampersands, + HEADRequest, + unescapeHTML, url_basename, RegexNotFoundError, ) @@ -18,6 +21,7 @@ def _media_xml_tag(tag): class MTVServicesInfoExtractor(InfoExtractor): + _MOBILE_TEMPLATE = None @staticmethod def _id_from_uri(uri): return uri.split(':')[-1] @@ -39,9 +43,29 @@ class MTVServicesInfoExtractor(InfoExtractor): else: return thumb_node.attrib['url'] - def _extract_video_formats(self, mdoc): - if re.match(r'.*/error_country_block\.swf$', mdoc.find('.//src').text) is not None: - raise ExtractorError('This video is not available from your country.', expected=True) + 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') + metrics_url = unescapeHTML(self._search_regex(r'