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