]>
Commit | Line | Data |
---|---|---|
2ffe3bc1 | 1 | # coding: utf-8 |
e9ea0bf1 S |
2 | from __future__ import unicode_literals |
3 | ||
2ffe3bc1 S |
4 | import re |
5 | ||
e9ea0bf1 | 6 | from .common import InfoExtractor |
c1ed1f70 | 7 | from ..utils import ( |
2ffe3bc1 | 8 | determine_ext, |
c1ed1f70 | 9 | int_or_none, |
4cbce88f | 10 | merge_dicts, |
2ffe3bc1 | 11 | parse_iso8601, |
376e1ad0 | 12 | qualities, |
3fc56635 S |
13 | try_get, |
14 | urljoin, | |
c1ed1f70 | 15 | ) |
e9ea0bf1 S |
16 | |
17 | ||
1934f3a0 | 18 | class NDRBaseIE(InfoExtractor): |
64997815 | 19 | def _real_extract(self, url): |
7e0dc613 S |
20 | mobj = re.match(self._VALID_URL, url) |
21 | display_id = next(group for group in mobj.groups() if group) | |
dc9d8f44 | 22 | id = mobj.group('id') |
2ffe3bc1 | 23 | webpage = self._download_webpage(url, display_id) |
dc9d8f44 | 24 | return self._extract_embed(webpage, display_id, id) |
64997815 | 25 | |
1934f3a0 YCH |
26 | |
27 | class NDRIE(NDRBaseIE): | |
28 | IE_NAME = 'ndr' | |
2ffe3bc1 | 29 | IE_DESC = 'NDR.de - Norddeutscher Rundfunk' |
dc9d8f44 | 30 | _VALID_URL = r'https?://(?:www\.)?(?:daserste\.)?ndr\.de/(?:[^/]+/)*(?P<display_id>[^/?#]+),(?P<id>[\da-z]+)\.html' |
2ffe3bc1 S |
31 | _TESTS = [{ |
32 | # httpVideo, same content id | |
33 | 'url': 'http://www.ndr.de/fernsehen/Party-Poette-und-Parade,hafengeburtstag988.html', | |
34 | 'md5': '6515bc255dc5c5f8c85bbc38e035a659', | |
35 | 'info_dict': { | |
36 | 'id': 'hafengeburtstag988', | |
37 | 'display_id': 'Party-Poette-und-Parade', | |
38 | 'ext': 'mp4', | |
39 | 'title': 'Party, Pötte und Parade', | |
40 | 'description': 'md5:ad14f9d2f91d3040b6930c697e5f6b4c', | |
41 | 'uploader': 'ndrtv', | |
42 | 'timestamp': 1431108900, | |
43 | 'upload_date': '20150510', | |
44 | 'duration': 3498, | |
45 | }, | |
46 | 'params': { | |
47 | 'skip_download': True, | |
48 | }, | |
49 | }, { | |
50 | # httpVideo, different content id | |
51 | 'url': 'http://www.ndr.de/sport/fussball/40-Osnabrueck-spielt-sich-in-einen-Rausch,osna270.html', | |
52 | 'md5': '1043ff203eab307f0c51702ec49e9a71', | |
53 | 'info_dict': { | |
54 | 'id': 'osna272', | |
55 | 'display_id': '40-Osnabrueck-spielt-sich-in-einen-Rausch', | |
56 | 'ext': 'mp4', | |
57 | 'title': 'Osnabrück - Wehen Wiesbaden: Die Highlights', | |
58 | 'description': 'md5:32e9b800b3d2d4008103752682d5dc01', | |
59 | 'uploader': 'ndrtv', | |
60 | 'timestamp': 1442059200, | |
61 | 'upload_date': '20150912', | |
62 | 'duration': 510, | |
63 | }, | |
64 | 'params': { | |
65 | 'skip_download': True, | |
66 | }, | |
67 | }, { | |
68 | # httpAudio, same content id | |
69 | 'url': 'http://www.ndr.de/info/La-Valette-entgeht-der-Hinrichtung,audio51535.html', | |
70 | 'md5': 'bb3cd38e24fbcc866d13b50ca59307b8', | |
71 | 'info_dict': { | |
72 | 'id': 'audio51535', | |
73 | 'display_id': 'La-Valette-entgeht-der-Hinrichtung', | |
74 | 'ext': 'mp3', | |
75 | 'title': 'La Valette entgeht der Hinrichtung', | |
76 | 'description': 'md5:22f9541913a40fe50091d5cdd7c9f536', | |
77 | 'uploader': 'ndrinfo', | |
78 | 'timestamp': 1290626100, | |
79 | 'upload_date': '20140729', | |
80 | 'duration': 884, | |
81 | }, | |
82 | 'params': { | |
83 | 'skip_download': True, | |
84 | }, | |
8bdd16b4 | 85 | }, { |
86 | # with subtitles | |
87 | 'url': 'https://www.ndr.de/fernsehen/sendungen/extra_3/extra-3-Satiremagazin-mit-Christian-Ehring,sendung1091858.html', | |
88 | 'info_dict': { | |
89 | 'id': 'extra18674', | |
90 | 'display_id': 'extra-3-Satiremagazin-mit-Christian-Ehring', | |
91 | 'ext': 'mp4', | |
92 | 'title': 'Extra 3 vom 11.11.2020 mit Christian Ehring', | |
93 | 'description': 'md5:42ee53990a715eaaf4dc7f13a3bd56c6', | |
94 | 'uploader': 'ndrtv', | |
95 | 'upload_date': '20201113', | |
96 | 'duration': 1749, | |
97 | 'subtitles': { | |
98 | 'de': [{ | |
99 | 'ext': 'ttml', | |
100 | 'url': r're:^https://www\.ndr\.de.+', | |
101 | }], | |
102 | }, | |
103 | }, | |
104 | 'params': { | |
105 | 'skip_download': True, | |
106 | }, | |
107 | 'expected_warnings': ['Unable to download f4m manifest'], | |
01003d07 S |
108 | }, { |
109 | 'url': 'https://www.ndr.de/Fettes-Brot-Ferris-MC-und-Thees-Uhlmann-live-on-stage,festivalsommer116.html', | |
110 | 'only_matching': True, | |
2ffe3bc1 S |
111 | }] |
112 | ||
dc9d8f44 | 113 | def _extract_embed(self, webpage, display_id, id): |
2ffe3bc1 | 114 | embed_url = self._html_search_meta( |
4cbce88f S |
115 | 'embedURL', webpage, 'embed URL', |
116 | default=None) or self._search_regex( | |
117 | r'\bembedUrl["\']\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, | |
dc9d8f44 | 118 | 'embed URL', fatal=False, group='url') |
921dc153 | 119 | if embed_url is None: |
dc9d8f44 | 120 | return self.url_result('ndr:%s' % id, ie=NDREmbedBaseIE.ie_key()) |
2ffe3bc1 S |
121 | description = self._search_regex( |
122 | r'<p[^>]+itemprop="description">([^<]+)</p>', | |
9796a9b2 | 123 | webpage, 'description', default=None) or self._og_search_description(webpage) |
2ffe3bc1 S |
124 | timestamp = parse_iso8601( |
125 | self._search_regex( | |
9796a9b2 | 126 | r'<span[^>]+itemprop="(?:datePublished|uploadDate)"[^>]+content="([^"]+)"', |
4cbce88f S |
127 | webpage, 'upload date', default=None)) |
128 | info = self._search_json_ld(webpage, display_id, default={}) | |
129 | return merge_dicts({ | |
2ffe3bc1 S |
130 | '_type': 'url_transparent', |
131 | 'url': embed_url, | |
132 | 'display_id': display_id, | |
133 | 'description': description, | |
134 | 'timestamp': timestamp, | |
4cbce88f | 135 | }, info) |
1934f3a0 YCH |
136 | |
137 | ||
138 | class NJoyIE(NDRBaseIE): | |
2ffe3bc1 S |
139 | IE_NAME = 'njoy' |
140 | IE_DESC = 'N-JOY' | |
92519402 | 141 | _VALID_URL = r'https?://(?:www\.)?n-joy\.de/(?:[^/]+/)*(?:(?P<display_id>[^/?#]+),)?(?P<id>[\da-z]+)\.html' |
2ffe3bc1 S |
142 | _TESTS = [{ |
143 | # httpVideo, same content id | |
1934f3a0 YCH |
144 | 'url': 'http://www.n-joy.de/entertainment/comedy/comedy_contest/Benaissa-beim-NDR-Comedy-Contest,comedycontest2480.html', |
145 | 'md5': 'cb63be60cd6f9dd75218803146d8dc67', | |
146 | 'info_dict': { | |
64997815 | 147 | 'id': 'comedycontest2480', |
2ffe3bc1 | 148 | 'display_id': 'Benaissa-beim-NDR-Comedy-Contest', |
1934f3a0 YCH |
149 | 'ext': 'mp4', |
150 | 'title': 'Benaissa beim NDR Comedy Contest', | |
2ffe3bc1 S |
151 | 'description': 'md5:f057a6c4e1c728b10d33b5ffd36ddc39', |
152 | 'uploader': 'ndrtv', | |
153 | 'upload_date': '20141129', | |
1934f3a0 | 154 | 'duration': 654, |
2ffe3bc1 S |
155 | }, |
156 | 'params': { | |
157 | 'skip_download': True, | |
158 | }, | |
159 | }, { | |
160 | # httpVideo, different content id | |
161 | 'url': 'http://www.n-joy.de/musik/Das-frueheste-DJ-Set-des-Nordens-live-mit-Felix-Jaehn-,felixjaehn168.html', | |
162 | 'md5': '417660fffa90e6df2fda19f1b40a64d8', | |
163 | 'info_dict': { | |
164 | 'id': 'dockville882', | |
165 | 'display_id': 'Das-frueheste-DJ-Set-des-Nordens-live-mit-Felix-Jaehn-', | |
166 | 'ext': 'mp4', | |
167 | 'title': '"Ich hab noch nie" mit Felix Jaehn', | |
168 | 'description': 'md5:85dd312d53be1b99e1f998a16452a2f3', | |
169 | 'uploader': 'njoy', | |
170 | 'upload_date': '20150822', | |
171 | 'duration': 211, | |
172 | }, | |
173 | 'params': { | |
174 | 'skip_download': True, | |
175 | }, | |
7e0dc613 S |
176 | }, { |
177 | 'url': 'http://www.n-joy.de/radio/webradio/morningshow209.html', | |
178 | 'only_matching': True, | |
2ffe3bc1 S |
179 | }] |
180 | ||
dc9d8f44 | 181 | def _extract_embed(self, webpage, display_id, id): |
2ffe3bc1 S |
182 | video_id = self._search_regex( |
183 | r'<iframe[^>]+id="pp_([\da-z]+)"', webpage, 'embed id') | |
184 | description = self._search_regex( | |
185 | r'<div[^>]+class="subline"[^>]*>[^<]+</div>\s*<p>([^<]+)</p>', | |
186 | webpage, 'description', fatal=False) | |
187 | return { | |
188 | '_type': 'url_transparent', | |
189 | 'ie_key': 'NDREmbedBase', | |
190 | 'url': 'ndr:%s' % video_id, | |
191 | 'display_id': display_id, | |
192 | 'description': description, | |
1934f3a0 | 193 | } |
64997815 | 194 | |
195 | ||
2ffe3bc1 S |
196 | class NDREmbedBaseIE(InfoExtractor): |
197 | IE_NAME = 'ndr:embed:base' | |
198 | _VALID_URL = r'(?:ndr:(?P<id_s>[\da-z]+)|https?://www\.ndr\.de/(?P<id>[\da-z]+)-ppjson\.json)' | |
199 | _TESTS = [{ | |
200 | 'url': 'ndr:soundcheck3366', | |
201 | 'only_matching': True, | |
202 | }, { | |
203 | 'url': 'http://www.ndr.de/soundcheck3366-ppjson.json', | |
204 | 'only_matching': True, | |
205 | }] | |
64997815 | 206 | |
207 | def _real_extract(self, url): | |
2ffe3bc1 S |
208 | mobj = re.match(self._VALID_URL, url) |
209 | video_id = mobj.group('id') or mobj.group('id_s') | |
210 | ||
211 | ppjson = self._download_json( | |
212 | 'http://www.ndr.de/%s-ppjson.json' % video_id, video_id) | |
213 | ||
214 | playlist = ppjson['playlist'] | |
215 | ||
216 | formats = [] | |
217 | quality_key = qualities(('xs', 's', 'm', 'l', 'xl')) | |
218 | ||
219 | for format_id, f in playlist.items(): | |
220 | src = f.get('src') | |
221 | if not src: | |
222 | continue | |
223 | ext = determine_ext(src, None) | |
224 | if ext == 'f4m': | |
225 | formats.extend(self._extract_f4m_formats( | |
310ea466 S |
226 | src + '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id, |
227 | f4m_id='hds', fatal=False)) | |
2ffe3bc1 S |
228 | elif ext == 'm3u8': |
229 | formats.extend(self._extract_m3u8_formats( | |
310ea466 S |
230 | src, video_id, 'mp4', m3u8_id='hls', |
231 | entry_protocol='m3u8_native', fatal=False)) | |
2ffe3bc1 S |
232 | else: |
233 | quality = f.get('quality') | |
234 | ff = { | |
235 | 'url': src, | |
236 | 'format_id': quality or format_id, | |
237 | 'quality': quality_key(quality), | |
238 | } | |
239 | type_ = f.get('type') | |
240 | if type_ and type_.split('/')[0] == 'audio': | |
241 | ff['vcodec'] = 'none' | |
242 | ff['ext'] = ext or 'mp3' | |
243 | formats.append(ff) | |
244 | self._sort_formats(formats) | |
245 | ||
246 | config = playlist['config'] | |
247 | ||
248 | live = playlist.get('config', {}).get('streamType') in ['httpVideoLive', 'httpAudioLive'] | |
249 | title = config['title'] | |
250 | if live: | |
251 | title = self._live_title(title) | |
252 | uploader = ppjson.get('config', {}).get('branding') | |
253 | upload_date = ppjson.get('config', {}).get('publicationDate') | |
254 | duration = int_or_none(config.get('duration')) | |
255 | ||
3fc56635 S |
256 | thumbnails = [] |
257 | poster = try_get(config, lambda x: x['poster'], dict) or {} | |
258 | for thumbnail_id, thumbnail in poster.items(): | |
259 | thumbnail_url = urljoin(url, thumbnail.get('src')) | |
260 | if not thumbnail_url: | |
261 | continue | |
262 | thumbnails.append({ | |
263 | 'id': thumbnail.get('quality') or thumbnail_id, | |
264 | 'url': thumbnail_url, | |
265 | 'preference': quality_key(thumbnail.get('quality')), | |
266 | }) | |
2ffe3bc1 | 267 | |
8bdd16b4 | 268 | subtitles = {} |
269 | tracks = config.get('tracks') | |
270 | if tracks and isinstance(tracks, list): | |
271 | for track in tracks: | |
272 | if not isinstance(track, dict): | |
273 | continue | |
274 | track_url = urljoin(url, track.get('src')) | |
275 | if not track_url: | |
276 | continue | |
277 | subtitles.setdefault(track.get('srclang') or 'de', []).append({ | |
278 | 'url': track_url, | |
279 | 'ext': 'ttml', | |
280 | }) | |
281 | ||
2ffe3bc1 S |
282 | return { |
283 | 'id': video_id, | |
284 | 'title': title, | |
285 | 'is_live': live, | |
286 | 'uploader': uploader if uploader != '-' else None, | |
287 | 'upload_date': upload_date[0:8] if upload_date else None, | |
288 | 'duration': duration, | |
289 | 'thumbnails': thumbnails, | |
290 | 'formats': formats, | |
8bdd16b4 | 291 | 'subtitles': subtitles, |
2ffe3bc1 | 292 | } |
64997815 | 293 | |
294 | ||
295 | class NDREmbedIE(NDREmbedBaseIE): | |
296 | IE_NAME = 'ndr:embed' | |
dc9d8f44 | 297 | _VALID_URL = r'https?://(?:www\.)?(?:daserste\.)?ndr\.de/(?:[^/]+/)*(?P<id>[\da-z]+)-(?:player|externalPlayer)\.html' |
2ffe3bc1 | 298 | _TESTS = [{ |
64997815 | 299 | 'url': 'http://www.ndr.de/fernsehen/sendungen/ndr_aktuell/ndraktuell28488-player.html', |
2ffe3bc1 | 300 | 'md5': '8b9306142fe65bbdefb5ce24edb6b0a9', |
64997815 | 301 | 'info_dict': { |
302 | 'id': 'ndraktuell28488', | |
303 | 'ext': 'mp4', | |
304 | 'title': 'Norddeutschland begrüßt Flüchtlinge', | |
2ffe3bc1 S |
305 | 'is_live': False, |
306 | 'uploader': 'ndrtv', | |
307 | 'upload_date': '20150907', | |
64997815 | 308 | 'duration': 132, |
2ffe3bc1 S |
309 | }, |
310 | }, { | |
311 | 'url': 'http://www.ndr.de/ndr2/events/soundcheck/soundcheck3366-player.html', | |
312 | 'md5': '002085c44bae38802d94ae5802a36e78', | |
313 | 'info_dict': { | |
314 | 'id': 'soundcheck3366', | |
315 | 'ext': 'mp4', | |
316 | 'title': 'Ella Henderson braucht Vergleiche nicht zu scheuen', | |
317 | 'is_live': False, | |
318 | 'uploader': 'ndr2', | |
319 | 'upload_date': '20150912', | |
320 | 'duration': 3554, | |
321 | }, | |
322 | 'params': { | |
323 | 'skip_download': True, | |
324 | }, | |
325 | }, { | |
326 | 'url': 'http://www.ndr.de/info/audio51535-player.html', | |
327 | 'md5': 'bb3cd38e24fbcc866d13b50ca59307b8', | |
328 | 'info_dict': { | |
329 | 'id': 'audio51535', | |
330 | 'ext': 'mp3', | |
331 | 'title': 'La Valette entgeht der Hinrichtung', | |
332 | 'is_live': False, | |
333 | 'uploader': 'ndrinfo', | |
334 | 'upload_date': '20140729', | |
335 | 'duration': 884, | |
336 | }, | |
337 | 'params': { | |
338 | 'skip_download': True, | |
339 | }, | |
340 | }, { | |
341 | 'url': 'http://www.ndr.de/fernsehen/sendungen/visite/visite11010-externalPlayer.html', | |
342 | 'md5': 'ae57f80511c1e1f2fd0d0d3d31aeae7c', | |
343 | 'info_dict': { | |
344 | 'id': 'visite11010', | |
345 | 'ext': 'mp4', | |
346 | 'title': 'Visite - die ganze Sendung', | |
347 | 'is_live': False, | |
348 | 'uploader': 'ndrtv', | |
349 | 'upload_date': '20150902', | |
350 | 'duration': 3525, | |
351 | }, | |
352 | 'params': { | |
353 | 'skip_download': True, | |
354 | }, | |
355 | }, { | |
356 | # httpVideoLive | |
357 | 'url': 'http://www.ndr.de/fernsehen/livestream/livestream217-externalPlayer.html', | |
358 | 'info_dict': { | |
359 | 'id': 'livestream217', | |
360 | 'ext': 'flv', | |
ec85ded8 | 361 | 'title': r're:^NDR Fernsehen Niedersachsen \d{4}-\d{2}-\d{2} \d{2}:\d{2}$', |
2ffe3bc1 S |
362 | 'is_live': True, |
363 | 'upload_date': '20150910', | |
364 | }, | |
365 | 'params': { | |
366 | 'skip_download': True, | |
367 | }, | |
368 | }, { | |
369 | 'url': 'http://www.ndr.de/ndrkultur/audio255020-player.html', | |
370 | 'only_matching': True, | |
371 | }, { | |
372 | 'url': 'http://www.ndr.de/fernsehen/sendungen/nordtour/nordtour7124-player.html', | |
373 | 'only_matching': True, | |
374 | }, { | |
375 | 'url': 'http://www.ndr.de/kultur/film/videos/videoimport10424-player.html', | |
376 | 'only_matching': True, | |
377 | }, { | |
378 | 'url': 'http://www.ndr.de/fernsehen/sendungen/hamburg_journal/hamj43006-player.html', | |
379 | 'only_matching': True, | |
380 | }, { | |
381 | 'url': 'http://www.ndr.de/fernsehen/sendungen/weltbilder/weltbilder4518-player.html', | |
382 | 'only_matching': True, | |
383 | }, { | |
384 | 'url': 'http://www.ndr.de/fernsehen/doku952-player.html', | |
385 | 'only_matching': True, | |
386 | }] | |
64997815 | 387 | |
388 | ||
389 | class NJoyEmbedIE(NDREmbedBaseIE): | |
2ffe3bc1 | 390 | IE_NAME = 'njoy:embed' |
92519402 | 391 | _VALID_URL = r'https?://(?:www\.)?n-joy\.de/(?:[^/]+/)*(?P<id>[\da-z]+)-(?:player|externalPlayer)_[^/]+\.html' |
2ffe3bc1 S |
392 | _TESTS = [{ |
393 | # httpVideo | |
394 | 'url': 'http://www.n-joy.de/events/reeperbahnfestival/doku948-player_image-bc168e87-5263-4d6d-bd27-bb643005a6de_theme-n-joy.html', | |
395 | 'md5': '8483cbfe2320bd4d28a349d62d88bd74', | |
64997815 | 396 | 'info_dict': { |
2ffe3bc1 | 397 | 'id': 'doku948', |
64997815 | 398 | 'ext': 'mp4', |
2ffe3bc1 S |
399 | 'title': 'Zehn Jahre Reeperbahn Festival - die Doku', |
400 | 'is_live': False, | |
401 | 'upload_date': '20150807', | |
402 | 'duration': 1011, | |
403 | }, | |
404 | }, { | |
405 | # httpAudio | |
406 | 'url': 'http://www.n-joy.de/news_wissen/stefanrichter100-player_image-d5e938b1-f21a-4b9a-86b8-aaba8bca3a13_theme-n-joy.html', | |
407 | 'md5': 'd989f80f28ac954430f7b8a48197188a', | |
408 | 'info_dict': { | |
409 | 'id': 'stefanrichter100', | |
410 | 'ext': 'mp3', | |
411 | 'title': 'Interview mit einem Augenzeugen', | |
412 | 'is_live': False, | |
413 | 'uploader': 'njoy', | |
414 | 'upload_date': '20150909', | |
415 | 'duration': 140, | |
416 | }, | |
417 | 'params': { | |
418 | 'skip_download': True, | |
419 | }, | |
420 | }, { | |
421 | # httpAudioLive, no explicit ext | |
422 | 'url': 'http://www.n-joy.de/news_wissen/webradioweltweit100-player_image-3fec0484-2244-4565-8fb8-ed25fd28b173_theme-n-joy.html', | |
423 | 'info_dict': { | |
424 | 'id': 'webradioweltweit100', | |
425 | 'ext': 'mp3', | |
ec85ded8 | 426 | 'title': r're:^N-JOY Weltweit \d{4}-\d{2}-\d{2} \d{2}:\d{2}$', |
2ffe3bc1 S |
427 | 'is_live': True, |
428 | 'uploader': 'njoy', | |
429 | 'upload_date': '20150810', | |
430 | }, | |
431 | 'params': { | |
432 | 'skip_download': True, | |
433 | }, | |
434 | }, { | |
435 | 'url': 'http://www.n-joy.de/musik/dockville882-player_image-3905259e-0803-4764-ac72-8b7de077d80a_theme-n-joy.html', | |
436 | 'only_matching': True, | |
437 | }, { | |
438 | 'url': 'http://www.n-joy.de/radio/sendungen/morningshow/urlaubsfotos190-player_image-066a5df1-5c95-49ec-a323-941d848718db_theme-n-joy.html', | |
439 | 'only_matching': True, | |
440 | }, { | |
441 | 'url': 'http://www.n-joy.de/entertainment/comedy/krudetv290-player_image-ab261bfe-51bf-4bf3-87ba-c5122ee35b3d_theme-n-joy.html', | |
442 | 'only_matching': True, | |
443 | }] |