]>
Commit | Line | Data |
---|---|---|
331ae266 JMF |
1 | from __future__ import unicode_literals |
2 | ||
525daedd S |
3 | import re |
4 | ||
171ca612 | 5 | from .common import InfoExtractor |
83e8fce6 S |
6 | from ..compat import ( |
7 | compat_HTTPError, | |
8 | compat_str, | |
9 | ) | |
331ae266 | 10 | from ..utils import ( |
83e8fce6 S |
11 | determine_ext, |
12 | ExtractorError, | |
5c4a81d9 | 13 | fix_xml_ampersands, |
ee706f10 | 14 | int_or_none, |
5742c18b | 15 | orderedSet, |
944a3de2 | 16 | parse_duration, |
c9ea760e | 17 | qualities, |
609a61e3 | 18 | strip_jsonp, |
5c4a81d9 | 19 | unified_strdate, |
331ae266 JMF |
20 | ) |
21 | ||
22 | ||
b9b42f2e | 23 | class NPOBaseIE(InfoExtractor): |
04e0bac2 | 24 | def _get_token(self, video_id): |
aa9cc2ec S |
25 | return self._download_json( |
26 | 'http://ida.omroep.nl/app.php/auth', video_id, | |
27 | note='Downloading token')['token'] | |
04e0bac2 S |
28 | |
29 | ||
30 | class NPOIE(NPOBaseIE): | |
e118031e | 31 | IE_NAME = 'npo' |
359aa2fd | 32 | IE_DESC = 'npo.nl, ntr.nl, omroepwnl.nl, zapp.nl and npo3.nl' |
525daedd | 33 | _VALID_URL = r'''(?x) |
03f32a7e S |
34 | (?: |
35 | npo:| | |
36 | https?:// | |
37 | (?:www\.)? | |
38 | (?: | |
7dd5415c | 39 | npo\.nl/(?!(?:live|radio)/)(?:[^/]+/){2}| |
03f32a7e | 40 | ntr\.nl/(?:[^/]+/){2,}| |
f264c623 | 41 | omroepwnl\.nl/video/fragment/[^/]+__| |
c4e74964 | 42 | (?:zapp|npo3)\.nl/(?:[^/]+/){2,} |
03f32a7e | 43 | ) |
525daedd S |
44 | ) |
45 | (?P<id>[^/?#]+) | |
46 | ''' | |
331ae266 | 47 | |
83e8fce6 S |
48 | _TESTS = [{ |
49 | 'url': 'http://www.npo.nl/nieuwsuur/22-06-2014/VPWON_1220719', | |
50 | 'md5': '4b3f9c429157ec4775f2c9cb7b911016', | |
51 | 'info_dict': { | |
52 | 'id': 'VPWON_1220719', | |
53 | 'ext': 'm4v', | |
54 | 'title': 'Nieuwsuur', | |
55 | 'description': 'Dagelijks tussen tien en elf: nieuws, sport en achtergronden.', | |
56 | 'upload_date': '20140622', | |
331ae266 | 57 | }, |
83e8fce6 S |
58 | }, { |
59 | 'url': 'http://www.npo.nl/de-mega-mike-mega-thomas-show/27-02-2009/VARA_101191800', | |
60 | 'md5': 'da50a5787dbfc1603c4ad80f31c5120b', | |
61 | 'info_dict': { | |
62 | 'id': 'VARA_101191800', | |
63 | 'ext': 'm4v', | |
64 | 'title': 'De Mega Mike & Mega Thomas show: The best of.', | |
65 | 'description': 'md5:3b74c97fc9d6901d5a665aac0e5400f4', | |
66 | 'upload_date': '20090227', | |
67 | 'duration': 2400, | |
944a3de2 | 68 | }, |
83e8fce6 S |
69 | }, { |
70 | 'url': 'http://www.npo.nl/tegenlicht/25-02-2013/VPWON_1169289', | |
71 | 'md5': 'f8065e4e5a7824068ed3c7e783178f2c', | |
72 | 'info_dict': { | |
73 | 'id': 'VPWON_1169289', | |
74 | 'ext': 'm4v', | |
75 | 'title': 'Tegenlicht: Zwart geld. De toekomst komt uit Afrika', | |
76 | 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea', | |
77 | 'upload_date': '20130225', | |
78 | 'duration': 3000, | |
1ff30d7b | 79 | }, |
83e8fce6 S |
80 | }, { |
81 | 'url': 'http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706', | |
82 | 'info_dict': { | |
83 | 'id': 'WO_VPRO_043706', | |
84 | 'ext': 'm4v', | |
85 | 'title': 'De nieuwe mens - Deel 1', | |
86 | 'description': 'md5:518ae51ba1293ffb80d8d8ce90b74e4b', | |
87 | 'duration': 4680, | |
1ff30d7b | 88 | }, |
83e8fce6 S |
89 | 'params': { |
90 | 'skip_download': True, | |
91 | } | |
92 | }, { | |
c85f3683 | 93 | # non asf in streams |
83e8fce6 S |
94 | 'url': 'http://www.npo.nl/hoe-gaat-europa-verder-na-parijs/10-01-2015/WO_NOS_762771', |
95 | 'info_dict': { | |
96 | 'id': 'WO_NOS_762771', | |
97 | 'ext': 'mp4', | |
98 | 'title': 'Hoe gaat Europa verder na Parijs?', | |
f264c623 | 99 | }, |
83e8fce6 S |
100 | 'params': { |
101 | 'skip_download': True, | |
102 | } | |
103 | }, { | |
104 | 'url': 'http://www.ntr.nl/Aap-Poot-Pies/27/detail/Aap-poot-pies/VPWON_1233944#content', | |
105 | 'info_dict': { | |
106 | 'id': 'VPWON_1233944', | |
107 | 'ext': 'm4v', | |
108 | 'title': 'Aap, poot, pies', | |
109 | 'description': 'md5:c9c8005d1869ae65b858e82c01a91fde', | |
110 | 'upload_date': '20150508', | |
111 | 'duration': 599, | |
f264c623 | 112 | }, |
83e8fce6 S |
113 | 'params': { |
114 | 'skip_download': True, | |
115 | } | |
116 | }, { | |
117 | 'url': 'http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698', | |
118 | 'info_dict': { | |
119 | 'id': 'POW_00996502', | |
120 | 'ext': 'm4v', | |
121 | 'title': '''"Dit is wel een 'landslide'..."''', | |
122 | 'description': 'md5:f8d66d537dfb641380226e31ca57b8e8', | |
123 | 'upload_date': '20150508', | |
124 | 'duration': 462, | |
18abb743 | 125 | }, |
83e8fce6 S |
126 | 'params': { |
127 | 'skip_download': True, | |
e118031e | 128 | } |
4b8a984c S |
129 | }, { |
130 | # audio | |
131 | 'url': 'http://www.npo.nl/jouw-stad-rotterdam/29-01-2017/RBX_FUNX_6683215/RBX_FUNX_7601437', | |
132 | 'info_dict': { | |
133 | 'id': 'RBX_FUNX_6683215', | |
134 | 'ext': 'mp3', | |
135 | 'title': 'Jouw Stad Rotterdam', | |
136 | 'description': 'md5:db251505244f097717ec59fabc372d9f', | |
137 | }, | |
138 | 'params': { | |
139 | 'skip_download': True, | |
140 | } | |
83e8fce6 S |
141 | }, { |
142 | 'url': 'http://www.zapp.nl/de-bzt-show/gemist/KN_1687547', | |
143 | 'only_matching': True, | |
144 | }, { | |
145 | 'url': 'http://www.zapp.nl/de-bzt-show/filmpjes/POMS_KN_7315118', | |
146 | 'only_matching': True, | |
147 | }, { | |
148 | 'url': 'http://www.zapp.nl/beste-vrienden-quiz/extra-video-s/WO_NTR_1067990', | |
149 | 'only_matching': True, | |
359aa2fd | 150 | }, { |
151 | 'url': 'https://www.npo3.nl/3onderzoekt/16-09-2015/VPWON_1239870', | |
152 | 'only_matching': True, | |
83e8fce6 S |
153 | }, { |
154 | # live stream | |
155 | 'url': 'npo:LI_NL1_4188102', | |
156 | 'only_matching': True, | |
7dd5415c S |
157 | }, { |
158 | 'url': 'http://www.npo.nl/radio-gaga/13-06-2017/BNN_101383373', | |
159 | 'only_matching': True, | |
c4e74964 S |
160 | }, { |
161 | 'url': 'https://www.zapp.nl/1803-skelterlab/instructie-video-s/740-instructievideo-s/POMS_AT_11736927', | |
162 | 'only_matching': True, | |
83e8fce6 | 163 | }] |
331ae266 JMF |
164 | |
165 | def _real_extract(self, url): | |
04e0bac2 | 166 | video_id = self._match_id(url) |
d0df9292 | 167 | return self._get_info(video_id) |
331ae266 | 168 | |
d0df9292 | 169 | def _get_info(self, video_id): |
331ae266 | 170 | metadata = self._download_json( |
8d06a624 | 171 | 'http://e.omroep.nl/metadata/%s' % video_id, |
331ae266 JMF |
172 | video_id, |
173 | # We have to remove the javascript callback | |
609a61e3 | 174 | transform_source=strip_jsonp, |
331ae266 | 175 | ) |
04e0bac2 | 176 | |
b8adcec4 S |
177 | error = metadata.get('error') |
178 | if error: | |
179 | raise ExtractorError(error, expected=True) | |
180 | ||
525daedd S |
181 | # For some videos actual video id (prid) is different (e.g. for |
182 | # http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698 | |
183 | # video id is POMS_WNL_853698 but prid is POW_00996502) | |
184 | video_id = metadata.get('prid') or video_id | |
185 | ||
23fc384f S |
186 | # titel is too generic in some cases so utilize aflevering_titel as well |
187 | # when available (e.g. http://tegenlicht.vpro.nl/afleveringen/2014-2015/access-to-africa.html) | |
188 | title = metadata['titel'] | |
189 | sub_title = metadata.get('aflevering_titel') | |
190 | if sub_title and sub_title != title: | |
191 | title += ': %s' % sub_title | |
192 | ||
04e0bac2 | 193 | token = self._get_token(video_id) |
331ae266 | 194 | |
c9ea760e | 195 | formats = [] |
83e8fce6 S |
196 | urls = set() |
197 | ||
d1b61870 S |
198 | def is_legal_url(format_url): |
199 | return format_url and format_url not in urls and re.match( | |
200 | r'^(?:https?:)?//', format_url) | |
201 | ||
ee706f10 S |
202 | QUALITY_LABELS = ('Laag', 'Normaal', 'Hoog') |
203 | QUALITY_FORMATS = ('adaptive', 'wmv_sb', 'h264_sb', 'wmv_bb', 'h264_bb', 'wvc1_std', 'h264_std') | |
204 | ||
205 | quality_from_label = qualities(QUALITY_LABELS) | |
206 | quality_from_format_id = qualities(QUALITY_FORMATS) | |
83e8fce6 S |
207 | items = self._download_json( |
208 | 'http://ida.omroep.nl/app.php/%s' % video_id, video_id, | |
209 | 'Downloading formats JSON', query={ | |
210 | 'adaptive': 'yes', | |
211 | 'token': token, | |
212 | })['items'][0] | |
213 | for num, item in enumerate(items): | |
214 | item_url = item.get('url') | |
d1b61870 | 215 | if not is_legal_url(item_url): |
83e8fce6 S |
216 | continue |
217 | urls.add(item_url) | |
218 | format_id = self._search_regex( | |
219 | r'video/ida/([^/]+)', item_url, 'format id', | |
220 | default=None) | |
221 | ||
ee706f10 S |
222 | item_label = item.get('label') |
223 | ||
83e8fce6 | 224 | def add_format_url(format_url): |
ee706f10 S |
225 | width = int_or_none(self._search_regex( |
226 | r'(\d+)[xX]\d+', format_url, 'width', default=None)) | |
227 | height = int_or_none(self._search_regex( | |
228 | r'\d+[xX](\d+)', format_url, 'height', default=None)) | |
229 | if item_label in QUALITY_LABELS: | |
230 | quality = quality_from_label(item_label) | |
231 | f_id = item_label | |
232 | elif item_label in QUALITY_FORMATS: | |
233 | quality = quality_from_format_id(format_id) | |
234 | f_id = format_id | |
235 | else: | |
5616caf8 | 236 | quality, f_id = [None] * 2 |
83e8fce6 S |
237 | formats.append({ |
238 | 'url': format_url, | |
ee706f10 S |
239 | 'format_id': f_id, |
240 | 'width': width, | |
241 | 'height': height, | |
242 | 'quality': quality, | |
83e8fce6 | 243 | }) |
1ff30d7b | 244 | |
83e8fce6 | 245 | # Example: http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706 |
4b8a984c | 246 | if item.get('contentType') in ('url', 'audio'): |
83e8fce6 S |
247 | add_format_url(item_url) |
248 | continue | |
249 | ||
250 | try: | |
251 | stream_info = self._download_json( | |
252 | item_url + '&type=json', video_id, | |
253 | 'Downloading %s stream JSON' | |
ee706f10 | 254 | % item_label or item.get('format') or format_id or num) |
83e8fce6 S |
255 | except ExtractorError as ee: |
256 | if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 404: | |
257 | error = (self._parse_json( | |
258 | ee.cause.read().decode(), video_id, | |
259 | fatal=False) or {}).get('errorstring') | |
260 | if error: | |
261 | raise ExtractorError(error, expected=True) | |
262 | raise | |
263 | # Stream URL instead of JSON, example: npo:LI_NL1_4188102 | |
264 | if isinstance(stream_info, compat_str): | |
265 | if not stream_info.startswith('http'): | |
aa9cc2ec | 266 | continue |
83e8fce6 S |
267 | video_url = stream_info |
268 | # JSON | |
269 | else: | |
aa9cc2ec | 270 | video_url = stream_info.get('url') |
83e8fce6 S |
271 | if not video_url or video_url in urls: |
272 | continue | |
273 | urls.add(item_url) | |
274 | if determine_ext(video_url) == 'm3u8': | |
275 | formats.extend(self._extract_m3u8_formats( | |
276 | video_url, video_id, ext='mp4', | |
277 | entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) | |
278 | else: | |
279 | add_format_url(video_url) | |
280 | ||
281 | is_live = metadata.get('medium') == 'live' | |
282 | ||
283 | if not is_live: | |
284 | for num, stream in enumerate(metadata.get('streams', [])): | |
285 | stream_url = stream.get('url') | |
d1b61870 | 286 | if not is_legal_url(stream_url): |
1ff30d7b | 287 | continue |
83e8fce6 S |
288 | urls.add(stream_url) |
289 | # smooth streaming is not supported | |
290 | stream_type = stream.get('type', '').lower() | |
291 | if stream_type in ['ss', 'ms']: | |
292 | continue | |
293 | if stream_type == 'hds': | |
294 | f4m_formats = self._extract_f4m_formats( | |
295 | stream_url, video_id, fatal=False) | |
296 | # f4m downloader downloads only piece of live stream | |
297 | for f4m_format in f4m_formats: | |
298 | f4m_format['preference'] = -1 | |
299 | formats.extend(f4m_formats) | |
300 | elif stream_type == 'hls': | |
aa9cc2ec | 301 | formats.extend(self._extract_m3u8_formats( |
83e8fce6 S |
302 | stream_url, video_id, ext='mp4', fatal=False)) |
303 | # Example: http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706 | |
304 | elif '.asf' in stream_url: | |
305 | asx = self._download_xml( | |
306 | stream_url, video_id, | |
307 | 'Downloading stream %d ASX playlist' % num, | |
308 | transform_source=fix_xml_ampersands, fatal=False) | |
309 | if not asx: | |
310 | continue | |
311 | ref = asx.find('./ENTRY/Ref') | |
312 | if ref is None: | |
313 | continue | |
314 | video_url = ref.get('href') | |
315 | if not video_url or video_url in urls: | |
316 | continue | |
317 | urls.add(video_url) | |
1ff30d7b S |
318 | formats.append({ |
319 | 'url': video_url, | |
83e8fce6 S |
320 | 'ext': stream.get('formaat', 'asf'), |
321 | 'quality': stream.get('kwaliteit'), | |
322 | 'preference': -10, | |
1ff30d7b | 323 | }) |
83e8fce6 | 324 | else: |
a0977064 S |
325 | formats.append({ |
326 | 'url': stream_url, | |
327 | 'quality': stream.get('kwaliteit'), | |
328 | }) | |
1ff30d7b | 329 | |
9e91449c | 330 | self._sort_formats(formats) |
25e5ebf3 | 331 | |
9e91449c S |
332 | subtitles = {} |
333 | if metadata.get('tt888') == 'ja': | |
b9b42f2e JMF |
334 | subtitles['nl'] = [{ |
335 | 'ext': 'vtt', | |
56fc078d | 336 | 'url': 'http://tt888.omroep.nl/tt888/%s' % video_id, |
b9b42f2e | 337 | }] |
331ae266 JMF |
338 | |
339 | return { | |
340 | 'id': video_id, | |
83e8fce6 | 341 | 'title': self._live_title(title) if is_live else title, |
536b0700 | 342 | 'description': metadata.get('info'), |
944a3de2 S |
343 | 'thumbnail': metadata.get('images', [{'url': None}])[-1]['url'], |
344 | 'upload_date': unified_strdate(metadata.get('gidsdatum')), | |
345 | 'duration': parse_duration(metadata.get('tijdsduur')), | |
c9ea760e | 346 | 'formats': formats, |
25e5ebf3 | 347 | 'subtitles': subtitles, |
83e8fce6 | 348 | 'is_live': is_live, |
331ae266 | 349 | } |
d0df9292 JMF |
350 | |
351 | ||
04e0bac2 S |
352 | class NPOLiveIE(NPOBaseIE): |
353 | IE_NAME = 'npo.nl:live' | |
04e431cf | 354 | _VALID_URL = r'https?://(?:www\.)?npo\.nl/live(?:/(?P<id>[^/?#&]+))?' |
04e0bac2 | 355 | |
1591ba25 | 356 | _TESTS = [{ |
04e0bac2 S |
357 | 'url': 'http://www.npo.nl/live/npo-1', |
358 | 'info_dict': { | |
83e8fce6 | 359 | 'id': 'LI_NL1_4188102', |
04e0bac2 S |
360 | 'display_id': 'npo-1', |
361 | 'ext': 'mp4', | |
83e8fce6 | 362 | 'title': 're:^NPO 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', |
04e0bac2 S |
363 | 'is_live': True, |
364 | }, | |
365 | 'params': { | |
366 | 'skip_download': True, | |
367 | } | |
1591ba25 AG |
368 | }, { |
369 | 'url': 'http://www.npo.nl/live', | |
04e431cf | 370 | 'only_matching': True, |
1591ba25 | 371 | }] |
04e0bac2 S |
372 | |
373 | def _real_extract(self, url): | |
1591ba25 | 374 | display_id = self._match_id(url) or 'npo-1' |
04e0bac2 S |
375 | |
376 | webpage = self._download_webpage(url, display_id) | |
377 | ||
378 | live_id = self._search_regex( | |
7a577309 | 379 | [r'media-id="([^"]+)"', r'data-prid="([^"]+)"'], webpage, 'live id') |
04e0bac2 | 380 | |
04e0bac2 | 381 | return { |
83e8fce6 S |
382 | '_type': 'url_transparent', |
383 | 'url': 'npo:%s' % live_id, | |
384 | 'ie_key': NPOIE.ie_key(), | |
04e0bac2 S |
385 | 'id': live_id, |
386 | 'display_id': display_id, | |
04e0bac2 S |
387 | } |
388 | ||
389 | ||
171ca612 S |
390 | class NPORadioIE(InfoExtractor): |
391 | IE_NAME = 'npo.nl:radio' | |
392 | _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/(?P<id>[^/]+)/?$' | |
393 | ||
394 | _TEST = { | |
395 | 'url': 'http://www.npo.nl/radio/radio-1', | |
396 | 'info_dict': { | |
397 | 'id': 'radio-1', | |
398 | 'ext': 'mp3', | |
399 | 'title': 're:^NPO Radio 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', | |
400 | 'is_live': True, | |
401 | }, | |
402 | 'params': { | |
403 | 'skip_download': True, | |
404 | } | |
405 | } | |
406 | ||
407 | @staticmethod | |
408 | def _html_get_attribute_regex(attribute): | |
409 | return r'{0}\s*=\s*\'([^\']+)\''.format(attribute) | |
410 | ||
411 | def _real_extract(self, url): | |
412 | video_id = self._match_id(url) | |
413 | ||
414 | webpage = self._download_webpage(url, video_id) | |
415 | ||
416 | title = self._html_search_regex( | |
417 | self._html_get_attribute_regex('data-channel'), webpage, 'title') | |
418 | ||
419 | stream = self._parse_json( | |
420 | self._html_search_regex(self._html_get_attribute_regex('data-streams'), webpage, 'data-streams'), | |
421 | video_id) | |
422 | ||
423 | codec = stream.get('codec') | |
424 | ||
425 | return { | |
426 | 'id': video_id, | |
427 | 'url': stream['url'], | |
428 | 'title': self._live_title(title), | |
429 | 'acodec': codec, | |
430 | 'ext': codec, | |
431 | 'is_live': True, | |
432 | } | |
433 | ||
434 | ||
435 | class NPORadioFragmentIE(InfoExtractor): | |
436 | IE_NAME = 'npo.nl:radio:fragment' | |
437 | _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/[^/]+/fragment/(?P<id>\d+)' | |
438 | ||
439 | _TEST = { | |
440 | 'url': 'http://www.npo.nl/radio/radio-5/fragment/174356', | |
441 | 'md5': 'dd8cc470dad764d0fdc70a9a1e2d18c2', | |
442 | 'info_dict': { | |
443 | 'id': '174356', | |
444 | 'ext': 'mp3', | |
445 | 'title': 'Jubileumconcert Willeke Alberti', | |
446 | }, | |
447 | } | |
448 | ||
449 | def _real_extract(self, url): | |
450 | audio_id = self._match_id(url) | |
451 | ||
452 | webpage = self._download_webpage(url, audio_id) | |
453 | ||
454 | title = self._html_search_regex( | |
455 | r'href="/radio/[^/]+/fragment/%s" title="([^"]+)"' % audio_id, | |
456 | webpage, 'title') | |
457 | ||
458 | audio_url = self._search_regex( | |
459 | r"data-streams='([^']+)'", webpage, 'audio url') | |
460 | ||
461 | return { | |
462 | 'id': audio_id, | |
463 | 'url': audio_url, | |
464 | 'title': title, | |
465 | } | |
466 | ||
467 | ||
0dc5a86a S |
468 | class NPODataMidEmbedIE(InfoExtractor): |
469 | def _real_extract(self, url): | |
470 | display_id = self._match_id(url) | |
471 | webpage = self._download_webpage(url, display_id) | |
472 | video_id = self._search_regex( | |
473 | r'data-mid=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage, 'video_id', group='id') | |
474 | return { | |
475 | '_type': 'url_transparent', | |
476 | 'ie_key': 'NPO', | |
477 | 'url': 'npo:%s' % video_id, | |
478 | 'display_id': display_id | |
479 | } | |
480 | ||
481 | ||
482 | class SchoolTVIE(NPODataMidEmbedIE): | |
89f26028 | 483 | IE_NAME = 'schooltv' |
484 | _VALID_URL = r'https?://(?:www\.)?schooltv\.nl/video/(?P<id>[^/?#&]+)' | |
485 | ||
486 | _TEST = { | |
487 | 'url': 'http://www.schooltv.nl/video/ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam/', | |
488 | 'info_dict': { | |
489 | 'id': 'WO_NTR_429477', | |
490 | 'display_id': 'ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam', | |
491 | 'title': 'Ademhaling: De hele dag haal je adem. Maar wat gebeurt er dan eigenlijk in je lichaam?', | |
492 | 'ext': 'mp4', | |
493 | 'description': 'md5:abfa0ff690adb73fd0297fd033aaa631' | |
494 | }, | |
495 | 'params': { | |
496 | # Skip because of m3u8 download | |
497 | 'skip_download': True | |
498 | } | |
499 | } | |
500 | ||
0dc5a86a S |
501 | |
502 | class HetKlokhuisIE(NPODataMidEmbedIE): | |
dbc01fdb | 503 | IE_NAME = 'hetklokhuis' |
197224b7 | 504 | _VALID_URL = r'https?://(?:www\.)?hetklokhuis\.nl/[^/]+/\d+/(?P<id>[^/?#&]+)' |
0dc5a86a S |
505 | |
506 | _TEST = { | |
507 | 'url': 'http://hetklokhuis.nl/tv-uitzending/3471/Zwaartekrachtsgolven', | |
508 | 'info_dict': { | |
509 | 'id': 'VPWON_1260528', | |
510 | 'display_id': 'Zwaartekrachtsgolven', | |
511 | 'ext': 'm4v', | |
512 | 'title': 'Het Klokhuis: Zwaartekrachtsgolven', | |
513 | 'description': 'md5:c94f31fb930d76c2efa4a4a71651dd48', | |
514 | 'upload_date': '20170223', | |
515 | }, | |
516 | 'params': { | |
517 | 'skip_download': True | |
89f26028 | 518 | } |
0dc5a86a | 519 | } |
89f26028 | 520 | |
521 | ||
a3d8b381 S |
522 | class NPOPlaylistBaseIE(NPOIE): |
523 | def _real_extract(self, url): | |
524 | playlist_id = self._match_id(url) | |
525 | ||
526 | webpage = self._download_webpage(url, playlist_id) | |
527 | ||
528 | entries = [ | |
529 | self.url_result('npo:%s' % video_id if not video_id.startswith('http') else video_id) | |
5742c18b | 530 | for video_id in orderedSet(re.findall(self._PLAYLIST_ENTRY_RE, webpage)) |
a3d8b381 S |
531 | ] |
532 | ||
533 | playlist_title = self._html_search_regex( | |
534 | self._PLAYLIST_TITLE_RE, webpage, 'playlist title', | |
535 | default=None) or self._og_search_title(webpage) | |
536 | ||
537 | return self.playlist_result(entries, playlist_id, playlist_title) | |
538 | ||
539 | ||
540 | class VPROIE(NPOPlaylistBaseIE): | |
464e7924 | 541 | IE_NAME = 'vpro' |
b1d79888 S |
542 | _VALID_URL = r'https?://(?:www\.)?(?:(?:tegenlicht\.)?vpro|2doc)\.nl/(?:[^/]+/)*(?P<id>[^/]+)\.html' |
543 | _PLAYLIST_TITLE_RE = (r'<h1[^>]+class=["\'].*?\bmedia-platform-title\b.*?["\'][^>]*>([^<]+)', | |
544 | r'<h5[^>]+class=["\'].*?\bmedia-platform-subtitle\b.*?["\'][^>]*>([^<]+)') | |
a3d8b381 | 545 | _PLAYLIST_ENTRY_RE = r'data-media-id="([^"]+)"' |
d0df9292 JMF |
546 | |
547 | _TESTS = [ | |
548 | { | |
549 | 'url': 'http://tegenlicht.vpro.nl/afleveringen/2012-2013/de-toekomst-komt-uit-afrika.html', | |
550 | 'md5': 'f8065e4e5a7824068ed3c7e783178f2c', | |
551 | 'info_dict': { | |
552 | 'id': 'VPWON_1169289', | |
553 | 'ext': 'm4v', | |
5ba761eb | 554 | 'title': 'De toekomst komt uit Afrika', |
611ac379 | 555 | 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea', |
d0df9292 JMF |
556 | 'upload_date': '20130225', |
557 | }, | |
ddb19772 | 558 | 'skip': 'Video gone', |
d0df9292 | 559 | }, |
611ac379 S |
560 | { |
561 | 'url': 'http://www.vpro.nl/programmas/2doc/2015/sergio-herman.html', | |
562 | 'info_dict': { | |
563 | 'id': 'sergio-herman', | |
ddb19772 | 564 | 'title': 'sergio herman: fucking perfect', |
611ac379 S |
565 | }, |
566 | 'playlist_count': 2, | |
574f42d7 S |
567 | }, |
568 | { | |
569 | # playlist with youtube embed | |
570 | 'url': 'http://www.vpro.nl/programmas/2doc/2015/education-education.html', | |
571 | 'info_dict': { | |
572 | 'id': 'education-education', | |
ddb19772 | 573 | 'title': 'education education', |
574f42d7 S |
574 | }, |
575 | 'playlist_count': 2, | |
b1d79888 S |
576 | }, |
577 | { | |
578 | 'url': 'http://www.2doc.nl/documentaires/series/2doc/2015/oktober/de-tegenprestatie.html', | |
579 | 'info_dict': { | |
580 | 'id': 'de-tegenprestatie', | |
581 | 'title': 'De Tegenprestatie', | |
582 | }, | |
583 | 'playlist_count': 2, | |
584 | }, { | |
585 | 'url': 'http://www.2doc.nl/speel~VARA_101375237~mh17-het-verdriet-van-nederland~.html', | |
586 | 'info_dict': { | |
587 | 'id': 'VARA_101375237', | |
588 | 'ext': 'm4v', | |
589 | 'title': 'MH17: Het verdriet van Nederland', | |
590 | 'description': 'md5:09e1a37c1fdb144621e22479691a9f18', | |
591 | 'upload_date': '20150716', | |
592 | }, | |
593 | 'params': { | |
594 | # Skip because of m3u8 download | |
595 | 'skip_download': True | |
596 | }, | |
611ac379 | 597 | } |
d0df9292 JMF |
598 | ] |
599 | ||
03f32a7e | 600 | |
a3d8b381 | 601 | class WNLIE(NPOPlaylistBaseIE): |
f9dd86a1 | 602 | IE_NAME = 'wnl' |
03f32a7e | 603 | _VALID_URL = r'https?://(?:www\.)?omroepwnl\.nl/video/detail/(?P<id>[^/]+)__\d+' |
a3d8b381 S |
604 | _PLAYLIST_TITLE_RE = r'(?s)<h1[^>]+class="subject"[^>]*>(.+?)</h1>' |
605 | _PLAYLIST_ENTRY_RE = r'<a[^>]+href="([^"]+)"[^>]+class="js-mid"[^>]*>Deel \d+' | |
03f32a7e | 606 | |
a3d8b381 | 607 | _TESTS = [{ |
03f32a7e S |
608 | 'url': 'http://www.omroepwnl.nl/video/detail/vandaag-de-dag-6-mei__060515', |
609 | 'info_dict': { | |
610 | 'id': 'vandaag-de-dag-6-mei', | |
611 | 'title': 'Vandaag de Dag 6 mei', | |
612 | }, | |
613 | 'playlist_count': 4, | |
a3d8b381 | 614 | }] |
5742c18b S |
615 | |
616 | ||
617 | class AndereTijdenIE(NPOPlaylistBaseIE): | |
f9dd86a1 | 618 | IE_NAME = 'anderetijden' |
5742c18b S |
619 | _VALID_URL = r'https?://(?:www\.)?anderetijden\.nl/programma/(?:[^/]+/)+(?P<id>[^/?#&]+)' |
620 | _PLAYLIST_TITLE_RE = r'(?s)<h1[^>]+class=["\'].*?\bpage-title\b.*?["\'][^>]*>(.+?)</h1>' | |
621 | _PLAYLIST_ENTRY_RE = r'<figure[^>]+class=["\']episode-container episode-page["\'][^>]+data-prid=["\'](.+?)["\']' | |
622 | ||
623 | _TESTS = [{ | |
624 | 'url': 'http://anderetijden.nl/programma/1/Andere-Tijden/aflevering/676/Duitse-soldaten-over-de-Slag-bij-Arnhem', | |
625 | 'info_dict': { | |
626 | 'id': 'Duitse-soldaten-over-de-Slag-bij-Arnhem', | |
627 | 'title': 'Duitse soldaten over de Slag bij Arnhem', | |
628 | }, | |
629 | 'playlist_count': 3, | |
630 | }] |