]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/npo.py
[extractor] Use classmethod/property where possible
[yt-dlp.git] / yt_dlp / extractor / npo.py
1 import re
2
3 from .common import InfoExtractor
4 from ..compat import (
5 compat_HTTPError,
6 compat_str,
7 )
8 from ..utils import (
9 determine_ext,
10 ExtractorError,
11 fix_xml_ampersands,
12 int_or_none,
13 merge_dicts,
14 orderedSet,
15 parse_duration,
16 qualities,
17 str_or_none,
18 strip_jsonp,
19 unified_strdate,
20 unified_timestamp,
21 url_or_none,
22 urlencode_postdata,
23 )
24
25
26 class NPOBaseIE(InfoExtractor):
27 def _get_token(self, video_id):
28 return self._download_json(
29 'http://ida.omroep.nl/app.php/auth', video_id,
30 note='Downloading token')['token']
31
32
33 class NPOIE(NPOBaseIE):
34 IE_NAME = 'npo'
35 IE_DESC = 'npo.nl, ntr.nl, omroepwnl.nl, zapp.nl and npo3.nl'
36 _VALID_URL = r'''(?x)
37 (?:
38 npo:|
39 https?://
40 (?:www\.)?
41 (?:
42 npo\.nl/(?:[^/]+/)*|
43 (?:ntr|npostart)\.nl/(?:[^/]+/){2,}|
44 omroepwnl\.nl/video/fragment/[^/]+__|
45 (?:zapp|npo3)\.nl/(?:[^/]+/){2,}
46 )
47 )
48 (?P<id>[^/?#]+)
49 '''
50
51 _TESTS = [{
52 'url': 'http://www.npo.nl/nieuwsuur/22-06-2014/VPWON_1220719',
53 'md5': '4b3f9c429157ec4775f2c9cb7b911016',
54 'info_dict': {
55 'id': 'VPWON_1220719',
56 'ext': 'm4v',
57 'title': 'Nieuwsuur',
58 'description': 'Dagelijks tussen tien en elf: nieuws, sport en achtergronden.',
59 'upload_date': '20140622',
60 },
61 }, {
62 'url': 'http://www.npo.nl/de-mega-mike-mega-thomas-show/27-02-2009/VARA_101191800',
63 'md5': 'da50a5787dbfc1603c4ad80f31c5120b',
64 'info_dict': {
65 'id': 'VARA_101191800',
66 'ext': 'm4v',
67 'title': 'De Mega Mike & Mega Thomas show: The best of.',
68 'description': 'md5:3b74c97fc9d6901d5a665aac0e5400f4',
69 'upload_date': '20090227',
70 'duration': 2400,
71 },
72 }, {
73 'url': 'http://www.npo.nl/tegenlicht/25-02-2013/VPWON_1169289',
74 'md5': 'f8065e4e5a7824068ed3c7e783178f2c',
75 'info_dict': {
76 'id': 'VPWON_1169289',
77 'ext': 'm4v',
78 'title': 'Tegenlicht: Zwart geld. De toekomst komt uit Afrika',
79 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea',
80 'upload_date': '20130225',
81 'duration': 3000,
82 },
83 }, {
84 'url': 'http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706',
85 'info_dict': {
86 'id': 'WO_VPRO_043706',
87 'ext': 'm4v',
88 'title': 'De nieuwe mens - Deel 1',
89 'description': 'md5:518ae51ba1293ffb80d8d8ce90b74e4b',
90 'duration': 4680,
91 },
92 'params': {
93 'skip_download': True,
94 }
95 }, {
96 # non asf in streams
97 'url': 'http://www.npo.nl/hoe-gaat-europa-verder-na-parijs/10-01-2015/WO_NOS_762771',
98 'info_dict': {
99 'id': 'WO_NOS_762771',
100 'ext': 'mp4',
101 'title': 'Hoe gaat Europa verder na Parijs?',
102 },
103 'params': {
104 'skip_download': True,
105 }
106 }, {
107 'url': 'http://www.ntr.nl/Aap-Poot-Pies/27/detail/Aap-poot-pies/VPWON_1233944#content',
108 'info_dict': {
109 'id': 'VPWON_1233944',
110 'ext': 'm4v',
111 'title': 'Aap, poot, pies',
112 'description': 'md5:c9c8005d1869ae65b858e82c01a91fde',
113 'upload_date': '20150508',
114 'duration': 599,
115 },
116 'params': {
117 'skip_download': True,
118 }
119 }, {
120 'url': 'http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698',
121 'info_dict': {
122 'id': 'POW_00996502',
123 'ext': 'm4v',
124 'title': '''"Dit is wel een 'landslide'..."''',
125 'description': 'md5:f8d66d537dfb641380226e31ca57b8e8',
126 'upload_date': '20150508',
127 'duration': 462,
128 },
129 'params': {
130 'skip_download': True,
131 }
132 }, {
133 # audio
134 'url': 'http://www.npo.nl/jouw-stad-rotterdam/29-01-2017/RBX_FUNX_6683215/RBX_FUNX_7601437',
135 'info_dict': {
136 'id': 'RBX_FUNX_6683215',
137 'ext': 'mp3',
138 'title': 'Jouw Stad Rotterdam',
139 'description': 'md5:db251505244f097717ec59fabc372d9f',
140 },
141 'params': {
142 'skip_download': True,
143 }
144 }, {
145 'url': 'http://www.zapp.nl/de-bzt-show/gemist/KN_1687547',
146 'only_matching': True,
147 }, {
148 'url': 'http://www.zapp.nl/de-bzt-show/filmpjes/POMS_KN_7315118',
149 'only_matching': True,
150 }, {
151 'url': 'http://www.zapp.nl/beste-vrienden-quiz/extra-video-s/WO_NTR_1067990',
152 'only_matching': True,
153 }, {
154 'url': 'https://www.npo3.nl/3onderzoekt/16-09-2015/VPWON_1239870',
155 'only_matching': True,
156 }, {
157 # live stream
158 'url': 'npo:LI_NL1_4188102',
159 'only_matching': True,
160 }, {
161 'url': 'http://www.npo.nl/radio-gaga/13-06-2017/BNN_101383373',
162 'only_matching': True,
163 }, {
164 'url': 'https://www.zapp.nl/1803-skelterlab/instructie-video-s/740-instructievideo-s/POMS_AT_11736927',
165 'only_matching': True,
166 }, {
167 'url': 'https://www.npostart.nl/broodje-gezond-ei/28-05-2018/KN_1698996',
168 'only_matching': True,
169 }, {
170 'url': 'https://npo.nl/KN_1698996',
171 'only_matching': True,
172 }]
173
174 @classmethod
175 def suitable(cls, url):
176 return (False if any(ie.suitable(url)
177 for ie in (NPOLiveIE, NPORadioIE, NPORadioFragmentIE))
178 else super(NPOIE, cls).suitable(url))
179
180 def _real_extract(self, url):
181 video_id = self._match_id(url)
182 return self._get_info(url, video_id) or self._get_old_info(video_id)
183
184 def _get_info(self, url, video_id):
185 token = self._download_json(
186 'https://www.npostart.nl/api/token', video_id,
187 'Downloading token', headers={
188 'Referer': url,
189 'X-Requested-With': 'XMLHttpRequest',
190 })['token']
191
192 player = self._download_json(
193 'https://www.npostart.nl/player/%s' % video_id, video_id,
194 'Downloading player JSON', data=urlencode_postdata({
195 'autoplay': 0,
196 'share': 1,
197 'pageUrl': url,
198 'hasAdConsent': 0,
199 '_token': token,
200 }))
201
202 player_token = player['token']
203
204 drm = False
205 format_urls = set()
206 formats = []
207 for profile in ('hls', 'dash-widevine', 'dash-playready', 'smooth'):
208 streams = self._download_json(
209 'https://start-player.npo.nl/video/%s/streams' % video_id,
210 video_id, 'Downloading %s profile JSON' % profile, fatal=False,
211 query={
212 'profile': profile,
213 'quality': 'npo',
214 'tokenId': player_token,
215 'streamType': 'broadcast',
216 })
217 if not streams:
218 continue
219 stream = streams.get('stream')
220 if not isinstance(stream, dict):
221 continue
222 stream_url = url_or_none(stream.get('src'))
223 if not stream_url or stream_url in format_urls:
224 continue
225 format_urls.add(stream_url)
226 if stream.get('protection') is not None or stream.get('keySystemOptions') is not None:
227 drm = True
228 continue
229 stream_type = stream.get('type')
230 stream_ext = determine_ext(stream_url)
231 if stream_type == 'application/dash+xml' or stream_ext == 'mpd':
232 formats.extend(self._extract_mpd_formats(
233 stream_url, video_id, mpd_id='dash', fatal=False))
234 elif stream_type == 'application/vnd.apple.mpegurl' or stream_ext == 'm3u8':
235 formats.extend(self._extract_m3u8_formats(
236 stream_url, video_id, ext='mp4',
237 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
238 elif re.search(r'\.isml?/Manifest', stream_url):
239 formats.extend(self._extract_ism_formats(
240 stream_url, video_id, ism_id='mss', fatal=False))
241 else:
242 formats.append({
243 'url': stream_url,
244 })
245
246 if not formats:
247 if not self.get_param('allow_unplayable_formats') and drm:
248 self.report_drm(video_id)
249
250 self._sort_formats(formats)
251
252 info = {
253 'id': video_id,
254 'title': video_id,
255 'formats': formats,
256 }
257
258 embed_url = url_or_none(player.get('embedUrl'))
259 if embed_url:
260 webpage = self._download_webpage(
261 embed_url, video_id, 'Downloading embed page', fatal=False)
262 if webpage:
263 video = self._parse_json(
264 self._search_regex(
265 r'\bvideo\s*=\s*({.+?})\s*;', webpage, 'video',
266 default='{}'), video_id)
267 if video:
268 title = video.get('episodeTitle')
269 subtitles = {}
270 subtitles_list = video.get('subtitles')
271 if isinstance(subtitles_list, list):
272 for cc in subtitles_list:
273 cc_url = url_or_none(cc.get('src'))
274 if not cc_url:
275 continue
276 lang = str_or_none(cc.get('language')) or 'nl'
277 subtitles.setdefault(lang, []).append({
278 'url': cc_url,
279 })
280 return merge_dicts({
281 'title': title,
282 'description': video.get('description'),
283 'thumbnail': url_or_none(
284 video.get('still_image_url') or video.get('orig_image_url')),
285 'duration': int_or_none(video.get('duration')),
286 'timestamp': unified_timestamp(video.get('broadcastDate')),
287 'creator': video.get('channel'),
288 'series': video.get('title'),
289 'episode': title,
290 'episode_number': int_or_none(video.get('episodeNumber')),
291 'subtitles': subtitles,
292 }, info)
293
294 return info
295
296 def _get_old_info(self, video_id):
297 metadata = self._download_json(
298 'http://e.omroep.nl/metadata/%s' % video_id,
299 video_id,
300 # We have to remove the javascript callback
301 transform_source=strip_jsonp,
302 )
303
304 error = metadata.get('error')
305 if error:
306 raise ExtractorError(error, expected=True)
307
308 # For some videos actual video id (prid) is different (e.g. for
309 # http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698
310 # video id is POMS_WNL_853698 but prid is POW_00996502)
311 video_id = metadata.get('prid') or video_id
312
313 # titel is too generic in some cases so utilize aflevering_titel as well
314 # when available (e.g. http://tegenlicht.vpro.nl/afleveringen/2014-2015/access-to-africa.html)
315 title = metadata['titel']
316 sub_title = metadata.get('aflevering_titel')
317 if sub_title and sub_title != title:
318 title += ': %s' % sub_title
319
320 token = self._get_token(video_id)
321
322 formats = []
323 urls = set()
324
325 def is_legal_url(format_url):
326 return format_url and format_url not in urls and re.match(
327 r'^(?:https?:)?//', format_url)
328
329 QUALITY_LABELS = ('Laag', 'Normaal', 'Hoog')
330 QUALITY_FORMATS = ('adaptive', 'wmv_sb', 'h264_sb', 'wmv_bb', 'h264_bb', 'wvc1_std', 'h264_std')
331
332 quality_from_label = qualities(QUALITY_LABELS)
333 quality_from_format_id = qualities(QUALITY_FORMATS)
334 items = self._download_json(
335 'http://ida.omroep.nl/app.php/%s' % video_id, video_id,
336 'Downloading formats JSON', query={
337 'adaptive': 'yes',
338 'token': token,
339 })['items'][0]
340 for num, item in enumerate(items):
341 item_url = item.get('url')
342 if not is_legal_url(item_url):
343 continue
344 urls.add(item_url)
345 format_id = self._search_regex(
346 r'video/ida/([^/]+)', item_url, 'format id',
347 default=None)
348
349 item_label = item.get('label')
350
351 def add_format_url(format_url):
352 width = int_or_none(self._search_regex(
353 r'(\d+)[xX]\d+', format_url, 'width', default=None))
354 height = int_or_none(self._search_regex(
355 r'\d+[xX](\d+)', format_url, 'height', default=None))
356 if item_label in QUALITY_LABELS:
357 quality = quality_from_label(item_label)
358 f_id = item_label
359 elif item_label in QUALITY_FORMATS:
360 quality = quality_from_format_id(format_id)
361 f_id = format_id
362 else:
363 quality, f_id = [None] * 2
364 formats.append({
365 'url': format_url,
366 'format_id': f_id,
367 'width': width,
368 'height': height,
369 'quality': quality,
370 })
371
372 # Example: http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706
373 if item.get('contentType') in ('url', 'audio'):
374 add_format_url(item_url)
375 continue
376
377 try:
378 stream_info = self._download_json(
379 item_url + '&type=json', video_id,
380 'Downloading %s stream JSON'
381 % item_label or item.get('format') or format_id or num)
382 except ExtractorError as ee:
383 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 404:
384 error = (self._parse_json(
385 ee.cause.read().decode(), video_id,
386 fatal=False) or {}).get('errorstring')
387 if error:
388 raise ExtractorError(error, expected=True)
389 raise
390 # Stream URL instead of JSON, example: npo:LI_NL1_4188102
391 if isinstance(stream_info, compat_str):
392 if not stream_info.startswith('http'):
393 continue
394 video_url = stream_info
395 # JSON
396 else:
397 video_url = stream_info.get('url')
398 if not video_url or 'vodnotavailable.' in video_url or video_url in urls:
399 continue
400 urls.add(video_url)
401 if determine_ext(video_url) == 'm3u8':
402 formats.extend(self._extract_m3u8_formats(
403 video_url, video_id, ext='mp4',
404 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
405 else:
406 add_format_url(video_url)
407
408 is_live = metadata.get('medium') == 'live'
409
410 if not is_live:
411 for num, stream in enumerate(metadata.get('streams', [])):
412 stream_url = stream.get('url')
413 if not is_legal_url(stream_url):
414 continue
415 urls.add(stream_url)
416 # smooth streaming is not supported
417 stream_type = stream.get('type', '').lower()
418 if stream_type in ['ss', 'ms']:
419 continue
420 if stream_type == 'hds':
421 f4m_formats = self._extract_f4m_formats(
422 stream_url, video_id, fatal=False)
423 # f4m downloader downloads only piece of live stream
424 for f4m_format in f4m_formats:
425 f4m_format['preference'] = -5
426 formats.extend(f4m_formats)
427 elif stream_type == 'hls':
428 formats.extend(self._extract_m3u8_formats(
429 stream_url, video_id, ext='mp4', fatal=False))
430 # Example: http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706
431 elif '.asf' in stream_url:
432 asx = self._download_xml(
433 stream_url, video_id,
434 'Downloading stream %d ASX playlist' % num,
435 transform_source=fix_xml_ampersands, fatal=False)
436 if not asx:
437 continue
438 ref = asx.find('./ENTRY/Ref')
439 if ref is None:
440 continue
441 video_url = ref.get('href')
442 if not video_url or video_url in urls:
443 continue
444 urls.add(video_url)
445 formats.append({
446 'url': video_url,
447 'ext': stream.get('formaat', 'asf'),
448 'quality': stream.get('kwaliteit'),
449 'preference': -10,
450 })
451 else:
452 formats.append({
453 'url': stream_url,
454 'quality': stream.get('kwaliteit'),
455 })
456
457 self._sort_formats(formats)
458
459 subtitles = {}
460 if metadata.get('tt888') == 'ja':
461 subtitles['nl'] = [{
462 'ext': 'vtt',
463 'url': 'http://tt888.omroep.nl/tt888/%s' % video_id,
464 }]
465
466 return {
467 'id': video_id,
468 'title': title,
469 'description': metadata.get('info'),
470 'thumbnail': metadata.get('images', [{'url': None}])[-1]['url'],
471 'upload_date': unified_strdate(metadata.get('gidsdatum')),
472 'duration': parse_duration(metadata.get('tijdsduur')),
473 'formats': formats,
474 'subtitles': subtitles,
475 'is_live': is_live,
476 }
477
478
479 class NPOLiveIE(NPOBaseIE):
480 IE_NAME = 'npo.nl:live'
481 _VALID_URL = r'https?://(?:www\.)?npo(?:start)?\.nl/live(?:/(?P<id>[^/?#&]+))?'
482
483 _TESTS = [{
484 'url': 'http://www.npo.nl/live/npo-1',
485 'info_dict': {
486 'id': 'LI_NL1_4188102',
487 'display_id': 'npo-1',
488 'ext': 'mp4',
489 'title': 're:^NPO 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
490 'is_live': True,
491 },
492 'params': {
493 'skip_download': True,
494 }
495 }, {
496 'url': 'http://www.npo.nl/live',
497 'only_matching': True,
498 }, {
499 'url': 'https://www.npostart.nl/live/npo-1',
500 'only_matching': True,
501 }]
502
503 def _real_extract(self, url):
504 display_id = self._match_id(url) or 'npo-1'
505
506 webpage = self._download_webpage(url, display_id)
507
508 live_id = self._search_regex(
509 [r'media-id="([^"]+)"', r'data-prid="([^"]+)"'], webpage, 'live id')
510
511 return {
512 '_type': 'url_transparent',
513 'url': 'npo:%s' % live_id,
514 'ie_key': NPOIE.ie_key(),
515 'id': live_id,
516 'display_id': display_id,
517 }
518
519
520 class NPORadioIE(InfoExtractor):
521 IE_NAME = 'npo.nl:radio'
522 _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/(?P<id>[^/]+)'
523
524 _TEST = {
525 'url': 'http://www.npo.nl/radio/radio-1',
526 'info_dict': {
527 'id': 'radio-1',
528 'ext': 'mp3',
529 'title': 're:^NPO Radio 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
530 'is_live': True,
531 },
532 'params': {
533 'skip_download': True,
534 }
535 }
536
537 @classmethod
538 def suitable(cls, url):
539 return False if NPORadioFragmentIE.suitable(url) else super(NPORadioIE, cls).suitable(url)
540
541 @staticmethod
542 def _html_get_attribute_regex(attribute):
543 return r'{0}\s*=\s*\'([^\']+)\''.format(attribute)
544
545 def _real_extract(self, url):
546 video_id = self._match_id(url)
547
548 webpage = self._download_webpage(url, video_id)
549
550 title = self._html_search_regex(
551 self._html_get_attribute_regex('data-channel'), webpage, 'title')
552
553 stream = self._parse_json(
554 self._html_search_regex(self._html_get_attribute_regex('data-streams'), webpage, 'data-streams'),
555 video_id)
556
557 codec = stream.get('codec')
558
559 return {
560 'id': video_id,
561 'url': stream['url'],
562 'title': title,
563 'acodec': codec,
564 'ext': codec,
565 'is_live': True,
566 }
567
568
569 class NPORadioFragmentIE(InfoExtractor):
570 IE_NAME = 'npo.nl:radio:fragment'
571 _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/[^/]+/fragment/(?P<id>\d+)'
572
573 _TEST = {
574 'url': 'http://www.npo.nl/radio/radio-5/fragment/174356',
575 'md5': 'dd8cc470dad764d0fdc70a9a1e2d18c2',
576 'info_dict': {
577 'id': '174356',
578 'ext': 'mp3',
579 'title': 'Jubileumconcert Willeke Alberti',
580 },
581 }
582
583 def _real_extract(self, url):
584 audio_id = self._match_id(url)
585
586 webpage = self._download_webpage(url, audio_id)
587
588 title = self._html_search_regex(
589 r'href="/radio/[^/]+/fragment/%s" title="([^"]+)"' % audio_id,
590 webpage, 'title')
591
592 audio_url = self._search_regex(
593 r"data-streams='([^']+)'", webpage, 'audio url')
594
595 return {
596 'id': audio_id,
597 'url': audio_url,
598 'title': title,
599 }
600
601
602 class NPODataMidEmbedIE(InfoExtractor):
603 def _real_extract(self, url):
604 display_id = self._match_id(url)
605 webpage = self._download_webpage(url, display_id)
606 video_id = self._search_regex(
607 r'data-mid=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage, 'video_id', group='id')
608 return {
609 '_type': 'url_transparent',
610 'ie_key': 'NPO',
611 'url': 'npo:%s' % video_id,
612 'display_id': display_id
613 }
614
615
616 class SchoolTVIE(NPODataMidEmbedIE):
617 IE_NAME = 'schooltv'
618 _VALID_URL = r'https?://(?:www\.)?schooltv\.nl/video/(?P<id>[^/?#&]+)'
619
620 _TEST = {
621 'url': 'http://www.schooltv.nl/video/ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam/',
622 'info_dict': {
623 'id': 'WO_NTR_429477',
624 'display_id': 'ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam',
625 'title': 'Ademhaling: De hele dag haal je adem. Maar wat gebeurt er dan eigenlijk in je lichaam?',
626 'ext': 'mp4',
627 'description': 'md5:abfa0ff690adb73fd0297fd033aaa631'
628 },
629 'params': {
630 # Skip because of m3u8 download
631 'skip_download': True
632 }
633 }
634
635
636 class HetKlokhuisIE(NPODataMidEmbedIE):
637 IE_NAME = 'hetklokhuis'
638 _VALID_URL = r'https?://(?:www\.)?hetklokhuis\.nl/[^/]+/\d+/(?P<id>[^/?#&]+)'
639
640 _TEST = {
641 'url': 'http://hetklokhuis.nl/tv-uitzending/3471/Zwaartekrachtsgolven',
642 'info_dict': {
643 'id': 'VPWON_1260528',
644 'display_id': 'Zwaartekrachtsgolven',
645 'ext': 'm4v',
646 'title': 'Het Klokhuis: Zwaartekrachtsgolven',
647 'description': 'md5:c94f31fb930d76c2efa4a4a71651dd48',
648 'upload_date': '20170223',
649 },
650 'params': {
651 'skip_download': True
652 }
653 }
654
655
656 class NPOPlaylistBaseIE(NPOIE):
657 def _real_extract(self, url):
658 playlist_id = self._match_id(url)
659
660 webpage = self._download_webpage(url, playlist_id)
661
662 entries = [
663 self.url_result('npo:%s' % video_id if not video_id.startswith('http') else video_id)
664 for video_id in orderedSet(re.findall(self._PLAYLIST_ENTRY_RE, webpage))
665 ]
666
667 playlist_title = self._html_search_regex(
668 self._PLAYLIST_TITLE_RE, webpage, 'playlist title',
669 default=None) or self._og_search_title(webpage)
670
671 return self.playlist_result(entries, playlist_id, playlist_title)
672
673
674 class VPROIE(NPOPlaylistBaseIE):
675 IE_NAME = 'vpro'
676 _VALID_URL = r'https?://(?:www\.)?(?:(?:tegenlicht\.)?vpro|2doc)\.nl/(?:[^/]+/)*(?P<id>[^/]+)\.html'
677 _PLAYLIST_TITLE_RE = (r'<h1[^>]+class=["\'].*?\bmedia-platform-title\b.*?["\'][^>]*>([^<]+)',
678 r'<h5[^>]+class=["\'].*?\bmedia-platform-subtitle\b.*?["\'][^>]*>([^<]+)')
679 _PLAYLIST_ENTRY_RE = r'data-media-id="([^"]+)"'
680
681 _TESTS = [
682 {
683 'url': 'http://tegenlicht.vpro.nl/afleveringen/2012-2013/de-toekomst-komt-uit-afrika.html',
684 'md5': 'f8065e4e5a7824068ed3c7e783178f2c',
685 'info_dict': {
686 'id': 'VPWON_1169289',
687 'ext': 'm4v',
688 'title': 'De toekomst komt uit Afrika',
689 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea',
690 'upload_date': '20130225',
691 },
692 'skip': 'Video gone',
693 },
694 {
695 'url': 'http://www.vpro.nl/programmas/2doc/2015/sergio-herman.html',
696 'info_dict': {
697 'id': 'sergio-herman',
698 'title': 'sergio herman: fucking perfect',
699 },
700 'playlist_count': 2,
701 },
702 {
703 # playlist with youtube embed
704 'url': 'http://www.vpro.nl/programmas/2doc/2015/education-education.html',
705 'info_dict': {
706 'id': 'education-education',
707 'title': 'education education',
708 },
709 'playlist_count': 2,
710 },
711 {
712 'url': 'http://www.2doc.nl/documentaires/series/2doc/2015/oktober/de-tegenprestatie.html',
713 'info_dict': {
714 'id': 'de-tegenprestatie',
715 'title': 'De Tegenprestatie',
716 },
717 'playlist_count': 2,
718 }, {
719 'url': 'http://www.2doc.nl/speel~VARA_101375237~mh17-het-verdriet-van-nederland~.html',
720 'info_dict': {
721 'id': 'VARA_101375237',
722 'ext': 'm4v',
723 'title': 'MH17: Het verdriet van Nederland',
724 'description': 'md5:09e1a37c1fdb144621e22479691a9f18',
725 'upload_date': '20150716',
726 },
727 'params': {
728 # Skip because of m3u8 download
729 'skip_download': True
730 },
731 }
732 ]
733
734
735 class WNLIE(NPOPlaylistBaseIE):
736 IE_NAME = 'wnl'
737 _VALID_URL = r'https?://(?:www\.)?omroepwnl\.nl/video/detail/(?P<id>[^/]+)__\d+'
738 _PLAYLIST_TITLE_RE = r'(?s)<h1[^>]+class="subject"[^>]*>(.+?)</h1>'
739 _PLAYLIST_ENTRY_RE = r'<a[^>]+href="([^"]+)"[^>]+class="js-mid"[^>]*>Deel \d+'
740
741 _TESTS = [{
742 'url': 'http://www.omroepwnl.nl/video/detail/vandaag-de-dag-6-mei__060515',
743 'info_dict': {
744 'id': 'vandaag-de-dag-6-mei',
745 'title': 'Vandaag de Dag 6 mei',
746 },
747 'playlist_count': 4,
748 }]
749
750
751 class AndereTijdenIE(NPOPlaylistBaseIE):
752 IE_NAME = 'anderetijden'
753 _VALID_URL = r'https?://(?:www\.)?anderetijden\.nl/programma/(?:[^/]+/)+(?P<id>[^/?#&]+)'
754 _PLAYLIST_TITLE_RE = r'(?s)<h1[^>]+class=["\'].*?\bpage-title\b.*?["\'][^>]*>(.+?)</h1>'
755 _PLAYLIST_ENTRY_RE = r'<figure[^>]+class=["\']episode-container episode-page["\'][^>]+data-prid=["\'](.+?)["\']'
756
757 _TESTS = [{
758 'url': 'http://anderetijden.nl/programma/1/Andere-Tijden/aflevering/676/Duitse-soldaten-over-de-Slag-bij-Arnhem',
759 'info_dict': {
760 'id': 'Duitse-soldaten-over-de-Slag-bij-Arnhem',
761 'title': 'Duitse soldaten over de Slag bij Arnhem',
762 },
763 'playlist_count': 3,
764 }]