1
0
mirror of https://github.com/l1ving/youtube-dl synced 2020-11-18 19:53:54 -08:00

[MTV] move German mtv site to new class

This commit is contained in:
Paul Hartmann 2015-08-26 00:06:44 +02:00
parent 17bc795e07
commit c9e729e34c
2 changed files with 39 additions and 32 deletions

View File

@ -340,6 +340,7 @@ from .mtv import (
MTVIE, MTVIE,
MTVServicesEmbeddedIE, MTVServicesEmbeddedIE,
MTVIggyIE, MTVIggyIE,
MTVDEIE,
) )
from .muenchentv import MuenchenTVIE from .muenchentv import MuenchenTVIE
from .musicplayon import MusicPlayOnIE from .musicplayon import MusicPlayOnIE

View File

@ -182,25 +182,6 @@ class MTVServicesInfoExtractor(InfoExtractor):
return self.playlist_result( return self.playlist_result(
[self._get_video_info(item) for item in idoc.findall('.//item')]) [self._get_video_info(item) for item in idoc.findall('.//item')])
def _get_videos_info_de(self, url, video_path):
"""Extract from German site mtv.de"""
webpage = self._download_webpage(url, video_path)
playlist_js = self._search_regex(r'<script>\s*window.pagePlaylist =(.*?\]);\s*window.trackingParams =', webpage, 'playlist', flags=re.DOTALL)
playlist = self._parse_json(playlist_js, video_path)
info = None
for item in playlist:
if item['video_path'] == video_path:
info = item
break
if info == None:
raise ExtractorError('video not in playlist')
mrss_url = info['mrss']
idoc = self._download_xml(
mrss_url, video_path,
'Downloading info', transform_source=fix_xml_ampersands)
return self.playlist_result(
[self._get_video_info(item) for item in idoc.findall('.//item')])
def _real_extract(self, url): def _real_extract(self, url):
title = url_basename(url) title = url_basename(url)
webpage = self._download_webpage(url, title) webpage = self._download_webpage(url, title)
@ -258,8 +239,7 @@ class MTVServicesEmbeddedIE(MTVServicesInfoExtractor):
class MTVIE(MTVServicesInfoExtractor): class MTVIE(MTVServicesInfoExtractor):
_VALID_URL = r'''(?x)^https?:// _VALID_URL = r'''(?x)^https?://
(?:(?:www\.)?mtv\.com/videos/.+?/(?P<videoid>[0-9]+)/[^/]+$| (?:(?:www\.)?mtv\.com/videos/.+?/(?P<videoid>[0-9]+)/[^/]+$|
m\.mtv\.com/videos/video\.rbml\?.*?id=(?P<mgid>[^&]+)| m\.mtv\.com/videos/video\.rbml\?.*?id=(?P<mgid>[^&]+))'''
(?:www\.)?mtv\.de(?P<video_path>/artists/.*))'''
_FEED_URL = 'http://www.mtv.com/player/embed/AS3/rss/' _FEED_URL = 'http://www.mtv.com/player/embed/AS3/rss/'
@ -274,15 +254,6 @@ class MTVIE(MTVServicesInfoExtractor):
'description': 'Album: Taylor Swift performs "Ours" for VH1 Storytellers at Harvey Mudd College.', 'description': 'Album: Taylor Swift performs "Ours" for VH1 Storytellers at Harvey Mudd College.',
}, },
}, },
{
'url': 'http://www.mtv.de/artists/10571-cro/videos/61131-traum',
'info_dict': {
'id': 'a50bc5f0b3aa4b3190aa',
'ext': 'mp4',
'title': 'cro-traum',
'description': 'Cro - Traum',
},
},
] ]
def _get_thumbnail_url(self, uri, itemdoc): def _get_thumbnail_url(self, uri, itemdoc):
@ -290,8 +261,6 @@ class MTVIE(MTVServicesInfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
if mobj.group('video_path'):
return self._get_videos_info_de(url, mobj.group('video_path'))
video_id = mobj.group('videoid') video_id = mobj.group('videoid')
uri = mobj.groupdict().get('mgid') uri = mobj.groupdict().get('mgid')
if uri is None: if uri is None:
@ -321,3 +290,40 @@ class MTVIggyIE(MTVServicesInfoExtractor):
} }
} }
_FEED_URL = 'http://all.mtvworldverticals.com/feed-xml/' _FEED_URL = 'http://all.mtvworldverticals.com/feed-xml/'
class MTVDEIE(MTVServicesInfoExtractor):
IE_NAME = 'mtv.de'
_VALID_URL = r'''(?x)^https?://(?:www\.)?mtv\.de(?P<video_path>/artists/.*)'''
_TESTS = [
{
'url': 'http://www.mtv.de/artists/10571-cro/videos/61131-traum',
'info_dict': {
'id': 'a50bc5f0b3aa4b3190aa',
'ext': 'mp4',
'title': 'cro-traum',
'description': 'Cro - Traum',
},
},
]
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
return self._get_videos_info(url, mobj.group('video_path'))
def _get_videos_info(self, url, video_path):
webpage = self._download_webpage(url, video_path)
playlist_js = self._search_regex(r'<script>\s*window.pagePlaylist =(.*?\]);\s*window.trackingParams =', webpage, 'playlist', flags=re.DOTALL)
playlist = self._parse_json(playlist_js, video_path)
info = None
for item in playlist:
if item['video_path'] == video_path:
info = item
break
if info == None:
raise ExtractorError('video not in playlist')
mrss_url = info['mrss']
idoc = self._download_xml(
mrss_url, video_path,
'Downloading info', transform_source=fix_xml_ampersands)
return self.playlist_result(
[self._get_video_info(item) for item in idoc.findall('.//item')])