2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
23 class WDRIE(InfoExtractor
):
24 _VALID_URL
= r
'https?://deviceids-medp\.wdr\.de/ondemand/\d+/(?P<id>\d+)\.js'
25 _GEO_COUNTRIES
= ['DE']
27 'url': 'http://deviceids-medp.wdr.de/ondemand/155/1557833.js',
31 'title': 'Biathlon-Staffel verpasst Podest bei Olympia-Generalprobe',
32 'upload_date': '20180112',
36 def _real_extract(self
, url
):
37 video_id
= self
._match
_id
(url
)
39 metadata
= self
._download
_json
(
40 url
, video_id
, transform_source
=strip_jsonp
)
42 is_live
= metadata
.get('mediaType') == 'live'
44 tracker_data
= metadata
['trackerData']
45 media_resource
= metadata
['mediaResource']
50 # check if the metadata contains a direct URL to a file
51 for kind
, media_resource
in media_resource
.items():
52 if kind
== 'captionsHash':
53 for ext
, url
in media_resource
.items():
54 subtitles
.setdefault('de', []).append({
60 if kind
not in ('dflt', 'alt'):
63 for tag_name
, medium_url
in media_resource
.items():
64 if tag_name
not in ('videoURL', 'audioURL'):
67 ext
= determine_ext(medium_url
)
69 formats
.extend(self
._extract
_m
3u8_formats
(
70 medium_url
, video_id
, 'mp4', 'm3u8_native',
73 manifest_url
= update_url_query(
74 medium_url
, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'}
)
75 formats
.extend(self
._extract
_f
4m
_formats
(
76 manifest_url
, video_id
, f4m_id
='hds', fatal
=False))
78 formats
.extend(self
._extract
_smil
_formats
(
79 medium_url
, 'stream', fatal
=False))
84 if ext
== 'unknown_video':
85 urlh
= self
._request
_webpage
(
86 medium_url
, video_id
, note
='Determining extension')
87 ext
= urlhandle_detect_ext(urlh
)
89 formats
.append(a_format
)
91 self
._sort
_formats
(formats
)
93 title
= tracker_data
['trackerClipTitle']
96 'id': tracker_data
.get('trackerClipId', video_id
),
97 'title': self
._live
_title
(title
) if is_live
else title
,
98 'alt_title': tracker_data
.get('trackerClipSubcategory'),
100 'subtitles': subtitles
,
101 'upload_date': unified_strdate(tracker_data
.get('trackerClipAirTime')),
106 class WDRPageIE(InfoExtractor
):
107 _CURRENT_MAUS_URL
= r
'https?://(?:www\.)wdrmaus.de/(?:[^/]+/){1,2}[^/?#]+\.php5'
108 _PAGE_REGEX
= r
'/(?:mediathek/)?(?:[^/]+/)*(?P<display_id>[^/]+)\.html'
109 _VALID_URL
= r
'https?://(?:www\d?\.)?(?:wdr\d?|sportschau)\.de' + _PAGE_REGEX
+ '|' + _CURRENT_MAUS_URL
113 'url': 'http://www1.wdr.de/mediathek/video/sendungen/doku-am-freitag/video-geheimnis-aachener-dom-100.html',
114 # HDS download, MD5 is unstable
118 'display_id': 'doku-am-freitag/video-geheimnis-aachener-dom-100',
119 'title': 'Geheimnis Aachener Dom',
120 'alt_title': 'Doku am Freitag',
121 'upload_date': '20160304',
122 'description': 'md5:87be8ff14d8dfd7a7ee46f0299b52318',
124 'subtitles': {'de': [{
125 'url': 'http://ondemand-ww.wdr.de/medp/fsk0/105/1058683/1058683_12220974.xml',
129 'skip': 'HTTP Error 404: Not Found',
132 'url': 'http://www1.wdr.de/mediathek/audio/wdr3/wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100.html',
133 'md5': 'f4c1f96d01cf285240f53ea4309663d8',
137 'display_id': 'wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100',
138 'title': 'Schriftstellerin Juli Zeh',
139 'alt_title': 'WDR 3 Gespräch am Samstag',
140 'upload_date': '20160312',
141 'description': 'md5:e127d320bc2b1f149be697ce044a3dd7',
145 'skip': 'HTTP Error 404: Not Found',
148 'url': 'http://www1.wdr.de/mediathek/video/live/index.html',
152 '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}$',
153 'alt_title': 'WDR Fernsehen Live',
154 'upload_date': '20150101',
158 'skip_download': True, # m3u8 download
162 'url': 'http://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html',
163 'playlist_mincount': 7,
165 'id': 'aktuelle-stunde-120',
169 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
173 'upload_date': 're:^[0-9]{8}$',
174 'title': 're:^Die Sendung mit der Maus vom [0-9.]{10}$',
176 'skip': 'The id changes from week to week because of the new episode'
179 'url': 'http://www.wdrmaus.de/filme/sachgeschichten/achterbahn.php5',
180 'md5': '803138901f6368ee497b4d195bb164f2',
184 'upload_date': '20130919',
185 'title': 'Sachgeschichte - Achterbahn ',
189 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html',
190 # Live stream, MD5 unstable
194 'title': r
're:^COSMO Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
195 'upload_date': '20160101',
198 'skip_download': True, # m3u8 download
202 'url': 'http://www.sportschau.de/handballem2018/handball-nationalmannschaft-em-stolperstein-vorrunde-100.html',
206 'title': 'DHB-Vizepräsident Bob Hanning - "Die Weltspitze ist extrem breit"',
207 'upload_date': '20180111',
210 'skip_download': True,
214 'url': 'http://www.sportschau.de/handballem2018/audio-vorschau---die-handball-em-startet-mit-grossem-favoritenfeld-100.html',
215 'only_matching': True,
219 def _real_extract(self
, url
):
220 mobj
= re
.match(self
._VALID
_URL
, url
)
221 display_id
= mobj
.group('display_id')
222 webpage
= self
._download
_webpage
(url
, display_id
)
226 # Article with several videos
228 # for wdr.de the data-extension is in a tag with the class "mediaLink"
229 # for wdr.de radio players, in a tag with the class "wdrrPlayerPlayBtn"
230 # for wdrmaus, in a tag with the class "videoButton" (previously a link
231 # to the page in a multiline "videoLink"-tag)
232 for mobj
in re
.finditer(
235 (["\'])(?
:mediaLink|wdrrPlayerPlayBtn|videoButton
)\b.*?\
1[^
>]+|
236 (["\'])videoLink\b.*?\2[\s]*>\n[^\n]*
237 )data-extension=(["\'])(?P
<data
>(?
:(?
!\
3).)+)\
3
239 media_link_obj = self._parse_json(
240 mobj.group('data'), display_id, transform_source=js_to_json,
242 if not media_link_obj:
245 media_link_obj, lambda x: x['mediaObj']['url'], compat_str)
247 entries.append(self.url_result(jsonp_url, ie=WDRIE.ie_key()))
249 # Playlist (e.g. https://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html)
253 compat_urlparse.urljoin(url, mobj.group('href')),
254 ie=WDRPageIE.ie_key())
255 for mobj in re.finditer(
256 r'<a[^>]+\bhref=(["\'])(?P<href>(?:(?!\1).)+)\1[^>]+\bdata-extension=',
257 webpage) if re.match(self._PAGE_REGEX, mobj.group('href'))
260 return self.playlist_result(entries, playlist_id=display_id)
263 class WDRElefantIE(InfoExtractor):
264 _VALID_URL = r'https?://(?:www\.)wdrmaus\.de/elefantenseite/#(?P<id>.+)'
266 'url': 'http://www.wdrmaus.de/elefantenseite/#folge_ostern_2015',
268 'title': 'Folge Oster-Spezial 2015',
272 'upload_date': '20150406'
275 'skip_download': True,
279 def _real_extract(self, url):
280 display_id = self._match_id(url)
282 # Table of Contents seems to always be at this address, so fetch it directly.
283 # The website fetches configurationJS.php5, which links to tableOfContentsJS.php5.
284 table_of_contents = self._download_json(
285 'https://www.wdrmaus.de/elefantenseite/data/tableOfContentsJS.php5',
287 if display_id not in table_of_contents:
288 raise ExtractorError(
289 'No entry in site\'s table of contents for this URL. '
290 'Is the fragment part of the URL (after the #) correct?',
292 xml_metadata_path = table_of_contents[display_id]['xmlPath']
293 xml_metadata = self._download_xml(
294 'https://www.wdrmaus.de/elefantenseite/' + xml_metadata_path,
296 zmdb_url_element = xml_metadata.find('./movie/zmdb_url')
297 if zmdb_url_element is None:
298 raise ExtractorError(
299 '%s is not a video' % display_id, expected=True)
300 return self.url_result(zmdb_url_element.text, ie=WDRIE.ie_key())
303 class WDRMobileIE(InfoExtractor):
304 _VALID_URL = r'''(?x
)
305 https?
://mobile
-ondemand\
.wdr\
.de
/
306 .*?
/fsk(?P
<age_limit
>[0-9]+)
308 (?P
<id>[0-9]+)_(?P
<title
>[0-9]+)'''
309 IE_NAME = 'wdr:mobile'
311 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
318 'skip': 'Problems with loading data.'
321 def _real_extract(self, url):
322 mobj = re.match(self._VALID_URL, url)
324 'id': mobj.group('id'),
325 'title': mobj.group('title'),
326 'age_limit': int(mobj.group('age_limit')),
329 'User-Agent': 'mobile',