From 2437a7ae4eee9fb893d42f2dd67f31555a07807e Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Sun, 21 May 2017 16:31:27 +0200 Subject: [PATCH] [wdr] add support for wdrmaus.de content pages as playlists The content pages directly contain multiple video players without linking to a separate page for each video, like the Mediathek pages do. Therefore, we cannot delegate loading the info_dict from a "video URL" (because it does not exist), but instead we have to grab each video separately from their video player and load the info_dict from the respective JSONP. On the other hand, Mediathek pages only contain links to the separate video pages, and no JSONP URL, so we still need to support the old way of loading each video page separately when playing the playlist. --- youtube_dl/extractor/wdr.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/wdr.py b/youtube_dl/extractor/wdr.py index b2b2c29ad..d31866d60 100644 --- a/youtube_dl/extractor/wdr.py +++ b/youtube_dl/extractor/wdr.py @@ -105,9 +105,9 @@ class WDRBaseIE(InfoExtractor): class WDRIE(WDRBaseIE): - _CURRENT_MAUS_URL = r'https?://(?:www\.)wdrmaus.de/(?:[^/]+/){1,2}[^/?#]+\.php5' + _WDR_MAUS_REGEX = r'https?://(?:www\.)wdrmaus.de/(?P(?:[^/]+/){1,4}[^/?#]+)\.php5' _PAGE_REGEX = r'/(?:mediathek/)?[^/]+/(?P[^/]+)/(?P.+)\.html' - _VALID_URL = r'(?Phttps?://(?:www\d\.)?wdr\d?\.de)' + _PAGE_REGEX + '|' + _CURRENT_MAUS_URL + _VALID_URL = r'(?Phttps?://(?:www\d\.)?wdr\d?\.de)' + _PAGE_REGEX + '|' + _WDR_MAUS_REGEX _TESTS = [ { @@ -187,6 +187,13 @@ class WDRIE(WDRBaseIE): 'description': 'Die Seite mit der Maus -', }, }, + { + 'url': 'http://www.wdrmaus.de/extras/mausthemen/eisenbahn/index.php5', + 'playlist_mincount': 8, + 'info_dict': { + 'id': 'extras/mausthemen/eisenbahn/index', + }, + }, { 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html', # Live stream, MD5 unstable @@ -210,6 +217,7 @@ class WDRIE(WDRBaseIE): jsonp_urls = self._extract_wdr_jsonp_urls(webpage, display_id) if not jsonp_urls: + # WDR Mediathek playlist pages contain links to the single video pages: entries = [ self.url_result(page_url + href[0], 'WDR') for href in re.findall( @@ -222,6 +230,19 @@ class WDRIE(WDRBaseIE): raise ExtractorError('No downloadable streams found', expected=True) + elif len(jsonp_urls) > 1: + # wdrmaus playlist pages directly contain the JSONP URLs: + display_id = mobj.group('display_id_maus') + entries = [ + self._extract_wdr_video_from_jsonp_url(jsonp_url, display_id) + for jsonp_url in jsonp_urls + ] + return { '_type': 'playlist', 'entries': entries, 'id': display_id } + + else: + # page with a single video + info_dict = self._extract_wdr_video_from_jsonp_url(jsonp_urls[0], display_id) + is_live = url_type == 'live' if is_live: