3 from .common
import InfoExtractor
22 class WDRIE(InfoExtractor
):
23 __API_URL_TPL
= '//deviceids-medp.wdr.de/ondemand/%s/%s'
24 _VALID_URL
= r
'''(?x)https?://
25 (?:deviceids-medp\.wdr\.de/ondemand/\d+/|
26 kinder\.wdr\.de/(?!mediathek/)[^#?]+-)
27 (?P<id>\d+)\.(?:js|assetjsonp)
29 _GEO_COUNTRIES
= ['DE']
31 'url': 'http://deviceids-medp.wdr.de/ondemand/155/1557833.js',
35 'title': 'Biathlon-Staffel verpasst Podest bei Olympia-Generalprobe',
36 'upload_date': '20180112',
40 def _asset_url(self
, wdr_id
):
41 id_len
= max(len(wdr_id
), 5)
42 return ''.join(('https:', self
.__API
_URL
_TPL
% (wdr_id
[:id_len
- 4], wdr_id
, ), '.js'))
44 def _real_extract(self
, url
):
45 video_id
= self
._match
_id
(url
)
47 if url
.startswith('wdr:'):
49 url
= self
._asset
_url
(video_id
)
51 metadata
= self
._download
_json
(
52 url
, video_id
, transform_source
=strip_jsonp
)
54 is_live
= metadata
.get('mediaType') == 'live'
56 tracker_data
= metadata
['trackerData']
57 title
= tracker_data
['trackerClipTitle']
58 media_resource
= metadata
['mediaResource']
63 # check if the metadata contains a direct URL to a file
64 for kind
, media
in media_resource
.items():
65 if kind
== 'captionsHash':
66 for ext
, url
in media
.items():
67 subtitles
.setdefault('de', []).append({
73 if kind
not in ('dflt', 'alt'):
75 if not isinstance(media
, dict):
78 for tag_name
, medium_url
in media
.items():
79 if tag_name
not in ('videoURL', 'audioURL'):
82 ext
= determine_ext(medium_url
)
84 formats
.extend(self
._extract
_m
3u8_formats
(
85 medium_url
, video_id
, 'mp4', 'm3u8_native',
88 manifest_url
= update_url_query(
89 medium_url
, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'}
)
90 formats
.extend(self
._extract
_f
4m
_formats
(
91 manifest_url
, video_id
, f4m_id
='hds', fatal
=False))
93 formats
.extend(self
._extract
_smil
_formats
(
94 medium_url
, 'stream', fatal
=False))
99 if ext
== 'unknown_video':
100 urlh
= self
._request
_webpage
(
101 medium_url
, video_id
, note
='Determining extension')
102 ext
= urlhandle_detect_ext(urlh
)
103 a_format
['ext'] = ext
104 formats
.append(a_format
)
106 caption_url
= media_resource
.get('captionURL')
112 captions_hash
= media_resource
.get('captionsHash')
113 if isinstance(captions_hash
, dict):
114 for ext
, format_url
in captions_hash
.items():
115 format_url
= url_or_none(format_url
)
118 subtitles
.setdefault('de', []).append({
120 'ext': determine_ext(format_url
, None) or ext
,
124 'id': tracker_data
.get('trackerClipId', video_id
),
126 'alt_title': tracker_data
.get('trackerClipSubcategory'),
128 'subtitles': subtitles
,
129 'upload_date': unified_strdate(tracker_data
.get('trackerClipAirTime')),
134 class WDRPageIE(WDRIE
): # XXX: Do not subclass from concrete IE
135 _MAUS_REGEX
= r
'https?://(?:www\.)wdrmaus.de/(?:[^/]+/)*?(?P<maus_id>[^/?#.]+)(?:/?|/index\.php5|\.php5)$'
136 _PAGE_REGEX
= r
'/(?:mediathek/)?(?:[^/]+/)*(?P<display_id>[^/]+)\.html'
137 _VALID_URL
= r
'https?://(?:www\d?\.)?(?:(?:kinder\.)?wdr\d?|sportschau)\.de' + _PAGE_REGEX
+ '|' + _MAUS_REGEX
141 'url': 'http://www1.wdr.de/mediathek/video/sendungen/doku-am-freitag/video-geheimnis-aachener-dom-100.html',
142 # HDS download, MD5 is unstable
146 'display_id': 'doku-am-freitag/video-geheimnis-aachener-dom-100',
147 'title': 'Geheimnis Aachener Dom',
148 'alt_title': 'Doku am Freitag',
149 'upload_date': '20160304',
150 'description': 'md5:87be8ff14d8dfd7a7ee46f0299b52318',
152 'subtitles': {'de': [{
153 'url': 'http://ondemand-ww.wdr.de/medp/fsk0/105/1058683/1058683_12220974.xml',
157 'skip': 'HTTP Error 404: Not Found',
160 'url': 'http://www1.wdr.de/mediathek/audio/wdr3/wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100.html',
161 'md5': 'f4c1f96d01cf285240f53ea4309663d8',
165 'display_id': 'wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100',
166 'title': 'Schriftstellerin Juli Zeh',
167 'alt_title': 'WDR 3 Gespräch am Samstag',
168 'upload_date': '20160312',
169 'description': 'md5:e127d320bc2b1f149be697ce044a3dd7',
173 'skip': 'HTTP Error 404: Not Found',
176 # FIXME: Asset JSON is directly embedded in webpage
177 'url': 'http://www1.wdr.de/mediathek/video/live/index.html',
181 '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}$',
182 'alt_title': 'WDR Fernsehen Live',
183 'upload_date': '20201112',
187 'skip_download': True, # m3u8 download
191 'url': 'http://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html',
192 'playlist_mincount': 6,
194 'id': 'aktuelle-stunde-120',
198 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
202 'upload_date': 're:^[0-9]{8}$',
203 'title': 're:^Die Sendung (?:mit der Maus )?vom [0-9.]{10}$',
205 'skip': 'The id changes from week to week because of the new episode'
208 'url': 'http://www.wdrmaus.de/filme/sachgeschichten/achterbahn.php5',
209 'md5': '803138901f6368ee497b4d195bb164f2',
213 'upload_date': '20130919',
214 'title': 'Sachgeschichte - Achterbahn ',
216 'skip': 'HTTP Error 404: Not Found',
219 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html',
220 # Live stream, MD5 unstable
224 'title': r
're:^COSMO Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
225 'alt_title': 'COSMO Livestream',
226 'live_status': 'is_live',
227 'upload_date': '20160101',
230 'skip_download': True, # m3u8 download
234 'url': 'http://www.sportschau.de/handballem2018/handball-nationalmannschaft-em-stolperstein-vorrunde-100.html',
238 'title': 'DHB-Vizepräsident Bob Hanning - "Die Weltspitze ist extrem breit"',
239 'upload_date': '20180111',
242 'skip_download': True,
244 'skip': 'HTTP Error 404: Not Found',
247 'url': 'http://www.sportschau.de/handballem2018/audio-vorschau---die-handball-em-startet-mit-grossem-favoritenfeld-100.html',
248 'only_matching': True,
251 'url': 'https://kinder.wdr.de/tv/die-sendung-mit-dem-elefanten/av/video-folge---astronaut-100.html',
252 'only_matching': True,
255 'url': 'https://www1.wdr.de/mediathek/video/sendungen/rockpalast/video-baroness---freak-valley-festival--100.html',
259 'title': 'Baroness - Freak Valley Festival 2022',
260 'alt_title': 'Rockpalast',
261 'upload_date': '20220725',
266 def _real_extract(self
, url
):
267 mobj
= self
._match
_valid
_url
(url
)
268 display_id
= dict_get(mobj
.groupdict(), ('display_id', 'maus_id'), 'wdrmaus')
269 webpage
= self
._download
_webpage
(url
, display_id
)
273 # Article with several videos
275 # for wdr.de the data-extension-ard is in a tag with the class "mediaLink"
276 # for wdr.de radio players, in a tag with the class "wdrrPlayerPlayBtn"
277 # for wdrmaus, in a tag with the class "videoButton" (previously a link
278 # to the page in a multiline "videoLink"-tag)
279 for mobj
in re
.finditer(
282 (["\'])(?
:mediaLink|wdrrPlayerPlayBtn|videoButton
)\b.*?\
1[^
>]+|
283 (["\'])videoLink\b.*?\2[\s]*>\n[^\n]*
284 )data-extension(?:-ard)?=(["\'])(?P
<data
>(?
:(?
!\
3).)+)\
3
286 media_link_obj = self._parse_json(
287 mobj.group('data'), display_id, transform_source=js_to_json,
289 if not media_link_obj:
292 media_link_obj, lambda x: x['mediaObj']['url'], compat_str)
294 # metadata, or player JS with ['ref'] giving WDR id, or just media, perhaps
295 clip_id = media_link_obj['mediaObj'].get('ref')
296 if jsonp_url.endswith('.assetjsonp'):
297 asset = self._download_json(
298 jsonp_url, display_id, fatal=False, transform_source=strip_jsonp)
299 clip_id = try_get(asset, lambda x: x['trackerData']['trackerClipId'], compat_str)
301 jsonp_url = self._asset_url(clip_id[4:])
302 entries.append(self.url_result(jsonp_url, ie=WDRIE.ie_key()))
304 # Playlist (e.g. https://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html)
308 compat_urlparse.urljoin(url, mobj.group('href')),
309 ie=WDRPageIE.ie_key())
310 for mobj in re.finditer(
311 r'<a[^>]+\bhref=(["\'])(?P<href>(?:(?!\1).)+)\1[^>]+\bdata-extension(?:-ard)?=',
312 webpage) if re.match(self._PAGE_REGEX, mobj.group('href'))
315 return self.playlist_result(entries, playlist_id=display_id)
318 class WDRElefantIE(InfoExtractor):
319 _VALID_URL = r'https?://(?:www\.)wdrmaus\.de/elefantenseite/#(?P<id>.+)'
321 'url': 'http://www.wdrmaus.de/elefantenseite/#elefantenkino_wippe',
322 # adaptive stream: unstable file MD5
328 'upload_date': '20071003'
332 def _real_extract(self, url):
333 display_id = self._match_id(url)
335 # Table of Contents seems to always be at this address, so fetch it directly.
336 # The website fetches configurationJS.php5, which links to tableOfContentsJS.php5.
337 table_of_contents = self._download_json(
338 'https://www.wdrmaus.de/elefantenseite/data/tableOfContentsJS.php5',
340 if display_id not in table_of_contents:
341 raise ExtractorError(
342 'No entry in site\'s table of contents for this URL. '
343 'Is the fragment part of the URL (after the #) correct?',
345 xml_metadata_path = table_of_contents[display_id]['xmlPath']
346 xml_metadata = self._download_xml(
347 'https://www.wdrmaus.de/elefantenseite/' + xml_metadata_path,
349 zmdb_url_element = xml_metadata.find('./movie/zmdb_url')
350 if zmdb_url_element is None:
351 raise ExtractorError(
352 '%s is not a video' % display_id, expected=True)
353 return self.url_result(zmdb_url_element.text, ie=WDRIE.ie_key())
356 class WDRMobileIE(InfoExtractor):
357 _VALID_URL = r'''(?x
)
358 https?
://mobile
-ondemand\
.wdr\
.de
/
359 .*?
/fsk(?P
<age_limit
>[0-9]+)
361 (?P
<id>[0-9]+)_(?P
<title
>[0-9]+)'''
362 IE_NAME = 'wdr:mobile'
363 _WORKING = False # no such domain
365 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
372 'skip': 'Problems with loading data.'
375 def _real_extract(self, url):
376 mobj = self._match_valid_url(url)
378 'id': mobj.group('id'),
379 'title': mobj.group('title'),
380 'age_limit': int(mobj.group('age_limit')),
383 'User-Agent': 'mobile',