4 from .common
import InfoExtractor
19 class WDRIE(InfoExtractor
):
20 __API_URL_TPL
= '//deviceids-medp.wdr.de/ondemand/%s/%s'
21 _VALID_URL
= r
'''(?x)https?://
22 (?:deviceids-medp\.wdr\.de/ondemand/\d+/|
23 kinder\.wdr\.de/(?!mediathek/)[^#?]+-)
24 (?P<id>\d+)\.(?:js|assetjsonp)
26 _GEO_COUNTRIES
= ['DE']
28 'url': 'http://deviceids-medp.wdr.de/ondemand/155/1557833.js',
32 'title': 'Biathlon-Staffel verpasst Podest bei Olympia-Generalprobe',
33 'upload_date': '20180112',
37 def _asset_url(self
, wdr_id
):
38 id_len
= max(len(wdr_id
), 5)
39 return ''.join(('https:', self
.__API
_URL
_TPL
% (wdr_id
[:id_len
- 4], wdr_id
), '.js'))
41 def _real_extract(self
, url
):
42 video_id
= self
._match
_id
(url
)
44 if url
.startswith('wdr:'):
46 url
= self
._asset
_url
(video_id
)
48 metadata
= self
._download
_json
(
49 url
, video_id
, transform_source
=strip_jsonp
)
51 is_live
= metadata
.get('mediaType') == 'live'
53 tracker_data
= metadata
['trackerData']
54 title
= tracker_data
['trackerClipTitle']
55 media_resource
= metadata
['mediaResource']
60 # check if the metadata contains a direct URL to a file
61 for kind
, media
in media_resource
.items():
62 if kind
== 'captionsHash':
63 for ext
, url
in media
.items():
64 subtitles
.setdefault('de', []).append({
70 if kind
not in ('dflt', 'alt'):
72 if not isinstance(media
, dict):
75 for tag_name
, medium_url
in media
.items():
76 if tag_name
not in ('videoURL', 'audioURL'):
79 ext
= determine_ext(medium_url
)
81 formats
.extend(self
._extract
_m
3u8_formats
(
82 medium_url
, video_id
, 'mp4', 'm3u8_native',
85 manifest_url
= update_url_query(
86 medium_url
, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'})
87 formats
.extend(self
._extract
_f
4m
_formats
(
88 manifest_url
, video_id
, f4m_id
='hds', fatal
=False))
90 formats
.extend(self
._extract
_smil
_formats
(
91 medium_url
, 'stream', fatal
=False))
96 if ext
== 'unknown_video':
97 urlh
= self
._request
_webpage
(
98 medium_url
, video_id
, note
='Determining extension')
99 ext
= urlhandle_detect_ext(urlh
)
100 a_format
['ext'] = ext
101 formats
.append(a_format
)
103 caption_url
= media_resource
.get('captionURL')
109 captions_hash
= media_resource
.get('captionsHash')
110 if isinstance(captions_hash
, dict):
111 for ext
, format_url
in captions_hash
.items():
112 format_url
= url_or_none(format_url
)
115 subtitles
.setdefault('de', []).append({
117 'ext': determine_ext(format_url
, None) or ext
,
121 'id': tracker_data
.get('trackerClipId', video_id
),
123 'alt_title': tracker_data
.get('trackerClipSubcategory'),
125 'subtitles': subtitles
,
126 'upload_date': unified_strdate(tracker_data
.get('trackerClipAirTime')),
131 class WDRPageIE(WDRIE
): # XXX: Do not subclass from concrete IE
132 _MAUS_REGEX
= r
'https?://(?:www\.)wdrmaus.de/(?:[^/]+/)*?(?P<maus_id>[^/?#.]+)(?:/?|/index\.php5|\.php5)$'
133 _PAGE_REGEX
= r
'/(?:mediathek/)?(?:[^/]+/)*(?P<display_id>[^/]+)\.html'
134 _VALID_URL
= r
'https?://(?:www\d?\.)?(?:(?:kinder\.)?wdr\d?|sportschau)\.de' + _PAGE_REGEX
+ '|' + _MAUS_REGEX
138 'url': 'http://www1.wdr.de/mediathek/video/sendungen/doku-am-freitag/video-geheimnis-aachener-dom-100.html',
139 # HDS download, MD5 is unstable
143 'display_id': 'doku-am-freitag/video-geheimnis-aachener-dom-100',
144 'title': 'Geheimnis Aachener Dom',
145 'alt_title': 'Doku am Freitag',
146 'upload_date': '20160304',
147 'description': 'md5:87be8ff14d8dfd7a7ee46f0299b52318',
149 'subtitles': {'de': [{
150 'url': 'http://ondemand-ww.wdr.de/medp/fsk0/105/1058683/1058683_12220974.xml',
154 'skip': 'HTTP Error 404: Not Found',
157 'url': 'http://www1.wdr.de/mediathek/audio/wdr3/wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100.html',
158 'md5': 'f4c1f96d01cf285240f53ea4309663d8',
162 'display_id': 'wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100',
163 'title': 'Schriftstellerin Juli Zeh',
164 'alt_title': 'WDR 3 Gespräch am Samstag',
165 'upload_date': '20160312',
166 'description': 'md5:e127d320bc2b1f149be697ce044a3dd7',
170 'skip': 'HTTP Error 404: Not Found',
173 # FIXME: Asset JSON is directly embedded in webpage
174 'url': 'http://www1.wdr.de/mediathek/video/live/index.html',
178 'title': r
're:^WDR Fernsehen im Livestream (?:\(nur in Deutschland erreichbar\) )?[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
179 'alt_title': 'WDR Fernsehen Live',
180 'upload_date': '20201112',
184 'skip_download': True, # m3u8 download
188 'url': 'http://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html',
189 'playlist_mincount': 6,
191 'id': 'aktuelle-stunde-120',
195 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
199 'upload_date': 're:^[0-9]{8}$',
200 'title': 're:^Die Sendung (?:mit der Maus )?vom [0-9.]{10}$',
202 'skip': 'The id changes from week to week because of the new episode',
205 'url': 'http://www.wdrmaus.de/filme/sachgeschichten/achterbahn.php5',
206 'md5': '803138901f6368ee497b4d195bb164f2',
210 'upload_date': '20130919',
211 'title': 'Sachgeschichte - Achterbahn ',
213 'skip': 'HTTP Error 404: Not Found',
216 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html',
217 # Live stream, MD5 unstable
221 'title': r
're:^COSMO Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
222 'alt_title': 'COSMO Livestream',
223 'live_status': 'is_live',
224 'upload_date': '20160101',
227 'skip_download': True, # m3u8 download
231 'url': 'http://www.sportschau.de/handballem2018/handball-nationalmannschaft-em-stolperstein-vorrunde-100.html',
235 'title': 'DHB-Vizepräsident Bob Hanning - "Die Weltspitze ist extrem breit"',
236 'upload_date': '20180111',
239 'skip_download': True,
241 'skip': 'HTTP Error 404: Not Found',
244 'url': 'http://www.sportschau.de/handballem2018/audio-vorschau---die-handball-em-startet-mit-grossem-favoritenfeld-100.html',
245 'only_matching': True,
248 'url': 'https://kinder.wdr.de/tv/die-sendung-mit-dem-elefanten/av/video-folge---astronaut-100.html',
249 'only_matching': True,
252 'url': 'https://www1.wdr.de/mediathek/video/sendungen/rockpalast/video-baroness---freak-valley-festival--100.html',
256 'title': 'Baroness - Freak Valley Festival 2022',
257 'alt_title': 'Rockpalast',
258 'upload_date': '20220725',
263 def _real_extract(self
, url
):
264 mobj
= self
._match
_valid
_url
(url
)
265 display_id
= dict_get(mobj
.groupdict(), ('display_id', 'maus_id'), 'wdrmaus')
266 webpage
= self
._download
_webpage
(url
, display_id
)
270 # Article with several videos
272 # for wdr.de the data-extension-ard is in a tag with the class "mediaLink"
273 # for wdr.de radio players, in a tag with the class "wdrrPlayerPlayBtn"
274 # for wdrmaus, in a tag with the class "videoButton" (previously a link
275 # to the page in a multiline "videoLink"-tag)
276 for mobj
in re
.finditer(
279 (["\'])(?
:mediaLink|wdrrPlayerPlayBtn|videoButton
)\b.*?\
1[^
>]+|
280 (["\'])videoLink\b.*?\2[\s]*>\n[^\n]*
281 )data-extension(?:-ard)?=(["\'])(?P
<data
>(?
:(?
!\
3).)+)\
3
283 media_link_obj = self._parse_json(
284 mobj.group('data'), display_id, transform_source=js_to_json,
286 if not media_link_obj:
289 media_link_obj, lambda x: x['mediaObj']['url'], str)
291 # metadata, or player JS with ['ref'] giving WDR id, or just media, perhaps
292 clip_id = media_link_obj['mediaObj'].get('ref')
293 if jsonp_url.endswith('.assetjsonp'):
294 asset = self._download_json(
295 jsonp_url, display_id, fatal=False, transform_source=strip_jsonp)
296 clip_id = try_get(asset, lambda x: x['trackerData']['trackerClipId'], str)
298 jsonp_url = self._asset_url(clip_id[4:])
299 entries.append(self.url_result(jsonp_url, ie=WDRIE.ie_key()))
301 # Playlist (e.g. https://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html)
305 urllib.parse.urljoin(url, mobj.group('href')),
306 ie=WDRPageIE.ie_key())
307 for mobj in re.finditer(
308 r'<a[^>]+\bhref=(["\'])(?P<href>(?:(?!\1).)+)\1[^>]+\bdata-extension(?:-ard)?=',
309 webpage) if re.match(self._PAGE_REGEX, mobj.group('href'))
312 return self.playlist_result(entries, playlist_id=display_id)
315 class WDRElefantIE(InfoExtractor):
316 _VALID_URL = r'https?://(?:www\.)wdrmaus\.de/elefantenseite/#(?P<id>.+)'
318 'url': 'http://www.wdrmaus.de/elefantenseite/#elefantenkino_wippe',
319 # adaptive stream: unstable file MD5
324 'upload_date': '20071003',
328 def _real_extract(self, url):
329 display_id = self._match_id(url)
331 # Table of Contents seems to always be at this address, so fetch it directly.
332 # The website fetches configurationJS.php5, which links to tableOfContentsJS.php5.
333 table_of_contents = self._download_json(
334 'https://www.wdrmaus.de/elefantenseite/data/tableOfContentsJS.php5',
336 if display_id not in table_of_contents:
337 raise ExtractorError(
338 'No entry in site\'s table of contents for this URL. '
339 'Is the fragment part of the URL (after the #) correct?',
341 xml_metadata_path = table_of_contents[display_id]['xmlPath']
342 xml_metadata = self._download_xml(
343 'https://www.wdrmaus.de/elefantenseite/' + xml_metadata_path,
345 zmdb_url_element = xml_metadata.find('./movie/zmdb_url')
346 if zmdb_url_element is None:
347 raise ExtractorError(
348 f'{display_id} is not a video', expected=True)
349 return self.url_result(zmdb_url_element.text, ie=WDRIE.ie_key())
352 class WDRMobileIE(InfoExtractor):
353 _VALID_URL = r'''(?x
)
354 https?
://mobile
-ondemand\
.wdr\
.de
/
355 .*?
/fsk(?P
<age_limit
>[0-9]+)
357 (?P
<id>[0-9]+)_(?P
<title
>[0-9]+)'''
358 IE_NAME = 'wdr:mobile'
359 _WORKING = False # no such domain
361 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
368 'skip': 'Problems with loading data.',
371 def _real_extract(self, url):
372 mobj = self._match_valid_url(url)
374 'id': mobj.group('id'),
375 'title': mobj.group('title'),
376 'age_limit': int(mobj.group('age_limit')),
379 'User-Agent': 'mobile',