1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
6 from .common import InfoExtractor
16 class WDRIE(InfoExtractor):
17 _CURRENT_MAUS_URL = r'https?://(?:www\.)wdrmaus.de/(?:[^/]+/){1,2}[^/?#]+\.php5'
18 _PAGE_REGEX = r'/mediathek/(?P<media_type>[^/]+)/(?P<type>[^/]+)/(?P<display_id>.+)\.html'
19 _VALID_URL = r'(?P<page_url>https?://(?:www\d\.)?wdr\d?\.de)' + _PAGE_REGEX + '|' + _CURRENT_MAUS_URL
23 'url': 'http://www1.wdr.de/mediathek/video/sendungen/doku-am-freitag/video-geheimnis-aachener-dom-100.html',
24 'md5': 'e58c39c3e30077141d258bf588700a7b',
28 'display_id': 'doku-am-freitag/video-geheimnis-aachener-dom-100',
29 'title': 'Geheimnis Aachener Dom',
30 'alt_title': 'Doku am Freitag',
31 'upload_date': '20160304',
32 'description': 'md5:87be8ff14d8dfd7a7ee46f0299b52318',
34 'subtitles': {'de': [{
35 'url': 'http://ondemand-ww.wdr.de/medp/fsk0/105/1058683/1058683_12220974.xml'
38 'skip': 'Page Not Found',
41 'url': 'http://www1.wdr.de/mediathek/audio/wdr3/wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100.html',
42 'md5': 'f4c1f96d01cf285240f53ea4309663d8',
46 'display_id': 'wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100',
47 'title': 'Schriftstellerin Juli Zeh',
48 'alt_title': 'WDR 3 Gespräch am Samstag',
49 'upload_date': '20160312',
50 'description': 'md5:e127d320bc2b1f149be697ce044a3dd7',
54 'skip': 'Page Not Found',
57 'url': 'http://www1.wdr.de/mediathek/video/live/index.html',
61 'display_id': 'index',
62 'title': r're:^WDR Fernsehen im Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
63 'alt_title': 'WDR Fernsehen Live',
65 'description': 'md5:ae2ff888510623bf8d4b115f95a9b7c9',
70 'skip_download': True, # m3u8 download
74 'url': 'http://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html',
75 'playlist_mincount': 10,
77 'id': 'aktuelle-stunde/aktuelle-stunde-120',
81 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
85 'upload_date': 're:^[0-9]{8}$',
86 'title': 're:^Die Sendung mit der Maus vom [0-9.]{10}$',
87 'description': '- Die Sendung mit der Maus -',
89 'skip': 'The id changes from week to week because of the new episode'
92 'url': 'http://www.wdrmaus.de/sachgeschichten/sachgeschichten/achterbahn.php5',
93 'md5': 'ca365705551e4bd5217490f3b0591290',
97 'upload_date': '20130919',
98 'title': 'Sachgeschichte - Achterbahn ',
99 'description': '- Die Sendung mit der Maus -',
102 'skip_download': True, # the file has different versions :(
107 def _real_extract(self, url):
108 mobj = re.match(self._VALID_URL, url)
109 url_type = mobj.group('type')
110 page_url = mobj.group('page_url')
111 display_id = mobj.group('display_id')
112 webpage = self._download_webpage(url, display_id)
114 # for wdr.de the data-extension is in a tag with the class "mediaLink"
115 # for wdrmaus its in a link to the page in a multiline "videoLink"-tag
116 json_metadata = self._html_search_regex(
117 r'class=(?:"mediaLink\b[^"]*"[^>]+|"videoLink\b[^"]*"[\s]*>\n[^\n]*)data-extension="([^"]+)"',
118 webpage, 'media link', default=None, flags=re.MULTILINE)
120 if not json_metadata:
122 self.url_result(page_url + href[0], 'WDR')
123 for href in re.findall(
124 r'<a href="(%s)"' % self._PAGE_REGEX,
128 if entries: # Playlist page
129 return self.playlist_result(entries, playlist_id=display_id)
131 raise ExtractorError('No downloadable streams found', expected=True)
133 media_link_obj = self._parse_json(json_metadata, display_id,
134 transform_source=js_to_json)
135 jsonp_url = media_link_obj['mediaObj']['url']
137 metadata = self._download_json(
138 jsonp_url, 'metadata', transform_source=strip_jsonp)
140 metadata_tracker_data = metadata['trackerData']
141 metadata_media_resource = metadata['mediaResource']
145 # check if the metadata contains a direct URL to a file
146 metadata_media_alt = metadata_media_resource.get('alt')
147 if metadata_media_alt:
148 for tag_name in ['videoURL', 'audioURL']:
149 if tag_name in metadata_media_alt:
150 alt_url = metadata_media_alt[tag_name]
151 if determine_ext(alt_url) == 'm3u8':
152 m3u_fmt = self._extract_m3u8_formats(
153 alt_url, display_id, 'mp4', 'm3u8_native',
155 formats.extend(m3u_fmt)
161 # check if there are flash-streams for this video
162 if 'dflt' in metadata_media_resource and 'videoURL' in metadata_media_resource['dflt']:
163 video_url = metadata_media_resource['dflt']['videoURL']
164 if video_url.endswith('.f4m'):
165 full_video_url = video_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18'
166 formats.extend(self._extract_f4m_formats(full_video_url, display_id, f4m_id='hds', fatal=False))
167 elif video_url.endswith('.smil'):
168 formats.extend(self._extract_smil_formats(video_url, 'stream', fatal=False))
171 caption_url = metadata_media_resource.get('captionURL')
177 title = metadata_tracker_data.get('trackerClipTitle')
178 is_live = url_type == 'live'
181 title = self._live_title(title)
183 elif 'trackerClipAirTime' in metadata_tracker_data:
184 upload_date = metadata_tracker_data['trackerClipAirTime']
186 upload_date = self._html_search_meta('DC.Date', webpage, 'upload date')
189 upload_date = unified_strdate(upload_date)
191 self._sort_formats(formats)
194 'id': metadata_tracker_data.get('trackerClipId', display_id),
195 'display_id': display_id,
197 'alt_title': metadata_tracker_data.get('trackerClipSubcategory'),
199 'upload_date': upload_date,
200 'description': self._html_search_meta('Description', webpage),
202 'subtitles': subtitles,
206 class WDRMobileIE(InfoExtractor):
207 _VALID_URL = r'''(?x)
208 https?://mobile-ondemand\.wdr\.de/
209 .*?/fsk(?P<age_limit>[0-9]+)
211 (?P<id>[0-9]+)_(?P<title>[0-9]+)'''
212 IE_NAME = 'wdr:mobile'
214 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
221 'skip': 'Problems with loading data.'
224 def _real_extract(self, url):
225 mobj = re.match(self._VALID_URL, url)
227 'id': mobj.group('id'),
228 'title': mobj.group('title'),
229 'age_limit': int(mobj.group('age_limit')),
232 'User-Agent': 'mobile',