2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
24 class WDRIE(InfoExtractor
):
25 _VALID_URL
= r
'''(?x)https?://
26 (?:deviceids-medp\.wdr\.de/ondemand/\d+/|
27 kinder\.wdr\.de/(?!mediathek/)[^#?]+-)
28 (?P<id>\d+)\.(?:js|assetjsonp)
30 _GEO_COUNTRIES
= ['DE']
32 'url': 'http://deviceids-medp.wdr.de/ondemand/155/1557833.js',
36 'title': 'Biathlon-Staffel verpasst Podest bei Olympia-Generalprobe',
37 'upload_date': '20180112',
41 def _real_extract(self
, url
):
42 video_id
= self
._match
_id
(url
)
44 metadata
= self
._download
_json
(
45 url
, video_id
, transform_source
=strip_jsonp
)
47 is_live
= metadata
.get('mediaType') == 'live'
49 tracker_data
= metadata
['trackerData']
50 title
= tracker_data
['trackerClipTitle']
51 media_resource
= metadata
['mediaResource']
56 # check if the metadata contains a direct URL to a file
57 for kind
, media
in media_resource
.items():
58 if kind
== 'captionsHash':
59 for ext
, url
in media
.items():
60 subtitles
.setdefault('de', []).append({
66 if kind
not in ('dflt', 'alt'):
68 if not isinstance(media
, dict):
71 for tag_name
, medium_url
in media
.items():
72 if tag_name
not in ('videoURL', 'audioURL'):
75 ext
= determine_ext(medium_url
)
77 formats
.extend(self
._extract
_m
3u8_formats
(
78 medium_url
, video_id
, 'mp4', 'm3u8_native',
81 manifest_url
= update_url_query(
82 medium_url
, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'}
)
83 formats
.extend(self
._extract
_f
4m
_formats
(
84 manifest_url
, video_id
, f4m_id
='hds', fatal
=False))
86 formats
.extend(self
._extract
_smil
_formats
(
87 medium_url
, 'stream', fatal
=False))
92 if ext
== 'unknown_video':
93 urlh
= self
._request
_webpage
(
94 medium_url
, video_id
, note
='Determining extension')
95 ext
= urlhandle_detect_ext(urlh
)
97 formats
.append(a_format
)
99 self
._sort
_formats
(formats
)
101 caption_url
= media_resource
.get('captionURL')
107 captions_hash
= media_resource
.get('captionsHash')
108 if isinstance(captions_hash
, dict):
109 for ext
, format_url
in captions_hash
.items():
110 format_url
= url_or_none(format_url
)
113 subtitles
.setdefault('de', []).append({
115 'ext': determine_ext(format_url
, None) or ext
,
119 'id': tracker_data
.get('trackerClipId', video_id
),
121 'alt_title': tracker_data
.get('trackerClipSubcategory'),
123 'subtitles': subtitles
,
124 'upload_date': unified_strdate(tracker_data
.get('trackerClipAirTime')),
129 class WDRPageIE(InfoExtractor
):
130 _CURRENT_MAUS_URL
= r
'https?://(?:www\.)wdrmaus.de/(?:[^/]+/){1,2}[^/?#]+\.php5'
131 _PAGE_REGEX
= r
'/(?:mediathek/)?(?:[^/]+/)*(?P<display_id>[^/]+)\.html'
132 _VALID_URL
= r
'https?://(?:www\d?\.)?(?:(?:kinder\.)?wdr\d?|sportschau)\.de' + _PAGE_REGEX
+ '|' + _CURRENT_MAUS_URL
136 'url': 'http://www1.wdr.de/mediathek/video/sendungen/doku-am-freitag/video-geheimnis-aachener-dom-100.html',
137 # HDS download, MD5 is unstable
141 'display_id': 'doku-am-freitag/video-geheimnis-aachener-dom-100',
142 'title': 'Geheimnis Aachener Dom',
143 'alt_title': 'Doku am Freitag',
144 'upload_date': '20160304',
145 'description': 'md5:87be8ff14d8dfd7a7ee46f0299b52318',
147 'subtitles': {'de': [{
148 'url': 'http://ondemand-ww.wdr.de/medp/fsk0/105/1058683/1058683_12220974.xml',
152 'skip': 'HTTP Error 404: Not Found',
155 'url': 'http://www1.wdr.de/mediathek/audio/wdr3/wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100.html',
156 'md5': 'f4c1f96d01cf285240f53ea4309663d8',
160 'display_id': 'wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100',
161 'title': 'Schriftstellerin Juli Zeh',
162 'alt_title': 'WDR 3 Gespräch am Samstag',
163 'upload_date': '20160312',
164 'description': 'md5:e127d320bc2b1f149be697ce044a3dd7',
168 'skip': 'HTTP Error 404: Not Found',
171 'url': 'http://www1.wdr.de/mediathek/video/live/index.html',
175 '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}$',
176 'alt_title': 'WDR Fernsehen Live',
177 'upload_date': '20150101',
181 'skip_download': True, # m3u8 download
185 'url': 'http://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html',
186 'playlist_mincount': 7,
188 'id': 'aktuelle-stunde-120',
192 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
196 'upload_date': 're:^[0-9]{8}$',
197 'title': 're:^Die Sendung mit der Maus vom [0-9.]{10}$',
199 'skip': 'The id changes from week to week because of the new episode'
202 'url': 'http://www.wdrmaus.de/filme/sachgeschichten/achterbahn.php5',
203 'md5': '803138901f6368ee497b4d195bb164f2',
207 'upload_date': '20130919',
208 'title': 'Sachgeschichte - Achterbahn ',
212 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html',
213 # Live stream, MD5 unstable
217 'title': r
're:^COSMO Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
218 'upload_date': '20160101',
221 'skip_download': True, # m3u8 download
225 'url': 'http://www.sportschau.de/handballem2018/handball-nationalmannschaft-em-stolperstein-vorrunde-100.html',
229 'title': 'DHB-Vizepräsident Bob Hanning - "Die Weltspitze ist extrem breit"',
230 'upload_date': '20180111',
233 'skip_download': True,
237 'url': 'http://www.sportschau.de/handballem2018/audio-vorschau---die-handball-em-startet-mit-grossem-favoritenfeld-100.html',
238 'only_matching': True,
241 'url': 'https://kinder.wdr.de/tv/die-sendung-mit-dem-elefanten/av/video-folge---astronaut-100.html',
242 'only_matching': True,
246 def _real_extract(self
, url
):
247 mobj
= self
._match
_valid
_url
(url
)
248 display_id
= mobj
.group('display_id')
249 webpage
= self
._download
_webpage
(url
, display_id
)
253 # Article with several videos
255 # for wdr.de the data-extension is in a tag with the class "mediaLink"
256 # for wdr.de radio players, in a tag with the class "wdrrPlayerPlayBtn"
257 # for wdrmaus, in a tag with the class "videoButton" (previously a link
258 # to the page in a multiline "videoLink"-tag)
259 for mobj
in re
.finditer(
262 (["\'])(?
:mediaLink|wdrrPlayerPlayBtn|videoButton
)\b.*?\
1[^
>]+|
263 (["\'])videoLink\b.*?\2[\s]*>\n[^\n]*
264 )data-extension=(["\'])(?P
<data
>(?
:(?
!\
3).)+)\
3
266 media_link_obj = self._parse_json(
267 mobj.group('data'), display_id, transform_source=js_to_json,
269 if not media_link_obj:
272 media_link_obj, lambda x: x['mediaObj']['url'], compat_str)
274 entries.append(self.url_result(jsonp_url, ie=WDRIE.ie_key()))
276 # Playlist (e.g. https://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html)
280 compat_urlparse.urljoin(url, mobj.group('href')),
281 ie=WDRPageIE.ie_key())
282 for mobj in re.finditer(
283 r'<a[^>]+\bhref=(["\'])(?P<href>(?:(?!\1).)+)\1[^>]+\bdata-extension=',
284 webpage) if re.match(self._PAGE_REGEX, mobj.group('href'))
287 return self.playlist_result(entries, playlist_id=display_id)
290 class WDRElefantIE(InfoExtractor):
291 _VALID_URL = r'https?://(?:www\.)wdrmaus\.de/elefantenseite/#(?P<id>.+)'
293 'url': 'http://www.wdrmaus.de/elefantenseite/#folge_ostern_2015',
295 'title': 'Folge Oster-Spezial 2015',
299 'upload_date': '20150406'
302 'skip_download': True,
306 def _real_extract(self, url):
307 display_id = self._match_id(url)
309 # Table of Contents seems to always be at this address, so fetch it directly.
310 # The website fetches configurationJS.php5, which links to tableOfContentsJS.php5.
311 table_of_contents = self._download_json(
312 'https://www.wdrmaus.de/elefantenseite/data/tableOfContentsJS.php5',
314 if display_id not in table_of_contents:
315 raise ExtractorError(
316 'No entry in site\'s table of contents for this URL. '
317 'Is the fragment part of the URL (after the #) correct?',
319 xml_metadata_path = table_of_contents[display_id]['xmlPath']
320 xml_metadata = self._download_xml(
321 'https://www.wdrmaus.de/elefantenseite/' + xml_metadata_path,
323 zmdb_url_element = xml_metadata.find('./movie/zmdb_url')
324 if zmdb_url_element is None:
325 raise ExtractorError(
326 '%s is not a video' % display_id, expected=True)
327 return self.url_result(zmdb_url_element.text, ie=WDRIE.ie_key())
330 class WDRMobileIE(InfoExtractor):
331 _VALID_URL = r'''(?x
)
332 https?
://mobile
-ondemand\
.wdr\
.de
/
333 .*?
/fsk(?P
<age_limit
>[0-9]+)
335 (?P
<id>[0-9]+)_(?P
<title
>[0-9]+)'''
336 IE_NAME = 'wdr:mobile'
338 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
345 'skip': 'Problems with loading data.'
348 def _real_extract(self, url):
349 mobj = self._match_valid_url(url)
351 'id': mobj.group('id'),
352 'title': mobj.group('title'),
353 'age_limit': int(mobj.group('age_limit')),
356 'User-Agent': 'mobile',