aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/mtv.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-01-22 00:21:27 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-01-22 00:21:27 +0100
commit6562df768d6af708a5aab6ed4964b250925e42b4 (patch)
treee09935cd995654cb3864e819747f33ab0f518243 /youtube_dl/extractor/mtv.py
parent06769acd717191ed61ce639314975816a8f7969c (diff)
parent47917f24c499f7949b04a23c35459ca69adae62d (diff)
downloadyoutube-dl-6562df768d6af708a5aab6ed4964b250925e42b4.tar.xz
Merge branch 'master' of github.com:rg3/youtube-dl
Conflicts: youtube_dl/extractor/mtv.py
Diffstat (limited to 'youtube_dl/extractor/mtv.py')
-rw-r--r--youtube_dl/extractor/mtv.py40
1 files changed, 33 insertions, 7 deletions
diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py
index 32cfa3632..af889a8af 100644
--- a/youtube_dl/extractor/mtv.py
+++ b/youtube_dl/extractor/mtv.py
@@ -1,7 +1,6 @@
from __future__ import unicode_literals
import re
-import xml.etree.ElementTree
from .common import InfoExtractor
from ..utils import (
@@ -9,6 +8,8 @@ from ..utils import (
ExtractorError,
find_xpath_attr,
fix_xml_ampersands,
+ url_basename,
+ RegexNotFoundError,
)
@@ -38,10 +39,9 @@ class MTVServicesInfoExtractor(InfoExtractor):
else:
return thumb_node.attrib['url']
- def _extract_video_formats(self, metadataXml):
- if '/error_country_block.swf' in metadataXml:
+ 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)
- mdoc = xml.etree.ElementTree.fromstring(metadataXml.encode('utf-8'))
formats = []
for rendition in mdoc.findall('.//rendition'):
@@ -67,8 +67,9 @@ class MTVServicesInfoExtractor(InfoExtractor):
mediagen_url = re.sub(r'&[^=]*?={.*?}(?=(&|$))', '', mediagen_url)
if 'acceptMethods' not in mediagen_url:
mediagen_url += '&acceptMethods=fms'
- mediagen_page = self._download_webpage(mediagen_url, video_id,
- 'Downloading video urls')
+
+ mediagen_doc = self._download_xml(mediagen_url, video_id,
+ 'Downloading video urls')
description_node = itemdoc.find('description')
if description_node is not None:
@@ -91,7 +92,7 @@ class MTVServicesInfoExtractor(InfoExtractor):
return {
'title': title,
- 'formats': self._extract_video_formats(mediagen_page),
+ 'formats': self._extract_video_formats(mediagen_doc),
'id': video_id,
'thumbnail': self._get_thumbnail_url(uri, itemdoc),
'description': description,
@@ -106,6 +107,17 @@ class MTVServicesInfoExtractor(InfoExtractor):
'Downloading info', transform_source=fix_xml_ampersands)
return [self._get_video_info(item) for item in idoc.findall('.//item')]
+ def _real_extract(self, url):
+ 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]
+ except RegexNotFoundError:
+ mgid = self._search_regex(r'data-mgid="(.*?)"', webpage, u'mgid')
+ return self._get_videos_info(mgid)
+
class MTVIE(MTVServicesInfoExtractor):
_VALID_URL = r'''(?x)^https?://
@@ -158,3 +170,17 @@ class MTVIE(MTVServicesInfoExtractor):
uri = self._html_search_regex(r'/uri/(.*?)\?', webpage, 'uri')
return self._get_videos_info(uri)
+
+
+class MTVIggyIE(MTVServicesInfoExtractor):
+ IE_NAME = 'mtviggy.com'
+ _VALID_URL = r'https?://www\.mtviggy\.com/videos/.+'
+ _TEST = {
+ 'url': 'http://www.mtviggy.com/videos/arcade-fire-behind-the-scenes-at-the-biggest-music-experiment-yet/',
+ 'info_dict': {
+ 'id': '984696',
+ 'ext': 'mp4',
+ 'title': 'Short',
+ }
+ }
+ _FEED_URL = 'http://all.mtvworldverticals.com/feed-xml/'