1
0
Fork 0
mirror of https://codeberg.org/polarisfm/youtube-dl.git synced 2024-12-27 01:56:52 +00:00

[mtvde] Simplify (Closes #6673)

This commit is contained in:
Sergey M․ 2015-08-28 21:24:54 +06:00
parent 071c10137b
commit 79fa9db0da

View file

@ -174,8 +174,11 @@ class MTVServicesInfoExtractor(InfoExtractor):
if self._LANG: if self._LANG:
info_url += 'lang=%s&' % self._LANG info_url += 'lang=%s&' % self._LANG
info_url += data info_url += data
return self._get_videos_info_from_url(info_url, video_id)
def _get_videos_info_from_url(self, url, video_id):
idoc = self._download_xml( idoc = self._download_xml(
info_url, video_id, url, video_id,
'Downloading info', transform_source=fix_xml_ampersands) 'Downloading info', transform_source=fix_xml_ampersands)
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')])
@ -289,39 +292,35 @@ class MTVIggyIE(MTVServicesInfoExtractor):
} }
_FEED_URL = 'http://all.mtvworldverticals.com/feed-xml/' _FEED_URL = 'http://all.mtvworldverticals.com/feed-xml/'
class MTVDEIE(MTVServicesInfoExtractor): class MTVDEIE(MTVServicesInfoExtractor):
IE_NAME = 'mtv.de' IE_NAME = 'mtv.de'
_VALID_URL = r'''(?x)^https?://(?:www\.)?mtv\.de(?P<video_path>/artists/.*)''' _VALID_URL = r'https?://(?:www\.)?mtv\.de/(?:artists|shows)/(?:[^/]+/)+(?P<id>\d+)-[^/#?]+/*(?:[#?].*)?$'
_TESTS = [ _TESTS = [{
{
'url': 'http://www.mtv.de/artists/10571-cro/videos/61131-traum', 'url': 'http://www.mtv.de/artists/10571-cro/videos/61131-traum',
'info_dict': { 'info_dict': {
'id': 'a50bc5f0b3aa4b3190aa', 'id': 'music_video-a50bc5f0b3aa4b3190aa',
'ext': 'mp4', 'ext': 'mp4',
'title': 'cro-traum', 'title': 'MusicVideo_cro-traum',
'description': 'Cro - Traum', 'description': 'Cro - Traum',
}, },
'params': {
# rtmp download
'skip_download': True,
}, },
] }]
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
return self._get_videos_info(url, mobj.group('video_path'))
webpage = self._download_webpage(url, video_id)
playlist = self._parse_json(
self._search_regex(
r'window\.pagePlaylist\s*=\s*(\[.+?\]);\n', webpage, 'page playlist'),
video_id)
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: for item in playlist:
if item['video_path'] == video_path: item_id = item.get('id')
info = item if item_id and compat_str(item_id) == video_id:
break return self._get_videos_info_from_url(item['mrss'], video_id)
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')])