X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fmtv.py;h=4521451ac933baabce786c76813e3e8407298b65;hb=5cef4ff09b8e77daab03b1cca508a941b5fd5fa0;hp=127fbeb4edde7fdcc7d76ac95ab67b09cb7823a7;hpb=bc4ba05fcbb20dfead6796b0878427b51c9f150a;p=youtube-dl diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py index 127fbeb4e..4521451ac 100644 --- a/youtube_dl/extractor/mtv.py +++ b/youtube_dl/extractor/mtv.py @@ -6,11 +6,13 @@ from .common import InfoExtractor from ..utils import ( compat_urllib_parse, ExtractorError, + find_xpath_attr, fix_xml_ampersands, url_basename, RegexNotFoundError, ) + def _media_xml_tag(tag): return '{http://search.yahoo.com/mrss/}%s' % tag @@ -65,6 +67,7 @@ class MTVServicesInfoExtractor(InfoExtractor): mediagen_url = re.sub(r'&[^=]*?={.*?}(?=(&|$))', '', mediagen_url) if 'acceptMethods' not in mediagen_url: mediagen_url += '&acceptMethods=fms' + mediagen_doc = self._download_xml(mediagen_url, video_id, 'Downloading video urls') @@ -74,8 +77,22 @@ class MTVServicesInfoExtractor(InfoExtractor): else: description = None + title_el = None + if title_el is None: + title_el = find_xpath_attr( + itemdoc, './/{http://search.yahoo.com/mrss/}category', + 'scheme', 'urn:mtvn:video_title') + if title_el is None: + title_el = itemdoc.find('.//{http://search.yahoo.com/mrss/}title') + if title_el is None: + title_el = itemdoc.find('.//title') + title = title_el.text + if title is None: + raise ExtractorError('Could not find video title') + title = title.strip() + return { - 'title': itemdoc.find('title').text, + 'title': title, 'formats': self._extract_video_formats(mediagen_doc), 'id': video_id, 'thumbnail': self._get_thumbnail_url(uri, itemdoc), @@ -95,11 +112,16 @@ class MTVServicesInfoExtractor(InfoExtractor): title = url_basename(url) webpage = self._download_webpage(url, title) try: - # the url is in the format http://media.mtvnservices.com/fb/{mgid}.swf - fb_url = self._og_search_video_url(webpage) - mgid = url_basename(fb_url).rpartition('.')[0] + # the url can be http://media.mtvnservices.com/fb/{mgid}.swf + # or http://media.mtvnservices.com/{mgid} + og_url = self._og_search_video_url(webpage) + mgid = url_basename(og_url) + if mgid.endswith('.swf'): + mgid = mgid[:-4] except RegexNotFoundError: - mgid = self._search_regex(r'data-mgid="(.*?)"', webpage, u'mgid') + mgid = self._search_regex( + [r'data-mgid="(.*?)"', r'swfobject.embedSWF\(".*?(mgid:.*?)"'], + webpage, u'mgid') return self._get_videos_info(mgid) @@ -164,7 +186,7 @@ class MTVIggyIE(MTVServicesInfoExtractor): 'info_dict': { 'id': '984696', 'ext': 'mp4', - 'title': 'Short', + 'title': 'Arcade Fire: Behind the Scenes at the Biggest Music Experiment Yet', } } _FEED_URL = 'http://all.mtvworldverticals.com/feed-xml/'