]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/npo.py
[extractor] Deprecate `_sort_formats`
[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 info = {
251 'id': video_id,
252 'title': video_id,
253 'formats': formats,
254 }
255
256 embed_url = url_or_none(player.get('embedUrl'))
257 if embed_url:
258 webpage = self._download_webpage(
259 embed_url, video_id, 'Downloading embed page', fatal=False)
260 if webpage:
261 video = self._parse_json(
262 self._search_regex(
263 r'\bvideo\s*=\s*({.+?})\s*;', webpage, 'video',
264 default='{}'), video_id)
265 if video:
266 title = video.get('episodeTitle')
267 subtitles = {}
268 subtitles_list = video.get('subtitles')
269 if isinstance(subtitles_list, list):
270 for cc in subtitles_list:
271 cc_url = url_or_none(cc.get('src'))
272 if not cc_url:
273 continue
274 lang = str_or_none(cc.get('language')) or 'nl'
275 subtitles.setdefault(lang, []).append({
276 'url': cc_url,
277 })
278 return merge_dicts({
279 'title': title,
280 'description': video.get('description'),
281 'thumbnail': url_or_none(
282 video.get('still_image_url') or video.get('orig_image_url')),
283 'duration': int_or_none(video.get('duration')),
284 'timestamp': unified_timestamp(video.get('broadcastDate')),
285 'creator': video.get('channel'),
286 'series': video.get('title'),
287 'episode': title,
288 'episode_number': int_or_none(video.get('episodeNumber')),
289 'subtitles': subtitles,
290 }, info)
291
292 return info
293
294 def _get_old_info(self, video_id):
295 metadata = self._download_json(
296 'http://e.omroep.nl/metadata/%s' % video_id,
297 video_id,
298 # We have to remove the javascript callback
299 transform_source=strip_jsonp,
300 )
301
302 error = metadata.get('error')
303 if error:
304 raise ExtractorError(error, expected=True)
305
306 # For some videos actual video id (prid) is different (e.g. for
307 # http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698
308 # video id is POMS_WNL_853698 but prid is POW_00996502)
309 video_id = metadata.get('prid') or video_id
310
311 # titel is too generic in some cases so utilize aflevering_titel as well
312 # when available (e.g. http://tegenlicht.vpro.nl/afleveringen/2014-2015/access-to-africa.html)
313 title = metadata['titel']
314 sub_title = metadata.get('aflevering_titel')
315 if sub_title and sub_title != title:
316 title += ': %s' % sub_title
317
318 token = self._get_token(video_id)
319
320 formats = []
321 urls = set()
322
323 def is_legal_url(format_url):
324 return format_url and format_url not in urls and re.match(
325 r'^(?:https?:)?//', format_url)
326
327 QUALITY_LABELS = ('Laag', 'Normaal', 'Hoog')
328 QUALITY_FORMATS = ('adaptive', 'wmv_sb', 'h264_sb', 'wmv_bb', 'h264_bb', 'wvc1_std', 'h264_std')
329
330 quality_from_label = qualities(QUALITY_LABELS)
331 quality_from_format_id = qualities(QUALITY_FORMATS)
332 items = self._download_json(
333 'http://ida.omroep.nl/app.php/%s' % video_id, video_id,
334 'Downloading formats JSON', query={
335 'adaptive': 'yes',
336 'token': token,
337 })['items'][0]
338 for num, item in enumerate(items):
339 item_url = item.get('url')
340 if not is_legal_url(item_url):
341 continue
342 urls.add(item_url)
343 format_id = self._search_regex(
344 r'video/ida/([^/]+)', item_url, 'format id',
345 default=None)
346
347 item_label = item.get('label')
348
349 def add_format_url(format_url):
350 width = int_or_none(self._search_regex(
351 r'(\d+)[xX]\d+', format_url, 'width', default=None))
352 height = int_or_none(self._search_regex(
353 r'\d+[xX](\d+)', format_url, 'height', default=None))
354 if item_label in QUALITY_LABELS:
355 quality = quality_from_label(item_label)
356 f_id = item_label
357 elif item_label in QUALITY_FORMATS:
358 quality = quality_from_format_id(format_id)
359 f_id = format_id
360 else:
361 quality, f_id = [None] * 2
362 formats.append({
363 'url': format_url,
364 'format_id': f_id,
365 'width': width,
366 'height': height,
367 'quality': quality,
368 })
369
370 # Example: http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706
371 if item.get('contentType') in ('url', 'audio'):
372 add_format_url(item_url)
373 continue
374
375 try:
376 stream_info = self._download_json(
377 item_url + '&type=json', video_id,
378 'Downloading %s stream JSON'
379 % item_label or item.get('format') or format_id or num)
380 except ExtractorError as ee:
381 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 404:
382 error = (self._parse_json(
383 ee.cause.read().decode(), video_id,
384 fatal=False) or {}).get('errorstring')
385 if error:
386 raise ExtractorError(error, expected=True)
387 raise
388 # Stream URL instead of JSON, example: npo:LI_NL1_4188102
389 if isinstance(stream_info, compat_str):
390 if not stream_info.startswith('http'):
391 continue
392 video_url = stream_info
393 # JSON
394 else:
395 video_url = stream_info.get('url')
396 if not video_url or 'vodnotavailable.' in video_url or video_url in urls:
397 continue
398 urls.add(video_url)
399 if determine_ext(video_url) == 'm3u8':
400 formats.extend(self._extract_m3u8_formats(
401 video_url, video_id, ext='mp4',
402 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
403 else:
404 add_format_url(video_url)
405
406 is_live = metadata.get('medium') == 'live'
407
408 if not is_live:
409 for num, stream in enumerate(metadata.get('streams', [])):
410 stream_url = stream.get('url')
411 if not is_legal_url(stream_url):
412 continue
413 urls.add(stream_url)
414 # smooth streaming is not supported
415 stream_type = stream.get('type', '').lower()
416 if stream_type in ['ss', 'ms']:
417 continue
418 if stream_type == 'hds':
419 f4m_formats = self._extract_f4m_formats(
420 stream_url, video_id, fatal=False)
421 # f4m downloader downloads only piece of live stream
422 for f4m_format in f4m_formats:
423 f4m_format['preference'] = -5
424 formats.extend(f4m_formats)
425 elif stream_type == 'hls':
426 formats.extend(self._extract_m3u8_formats(
427 stream_url, video_id, ext='mp4', fatal=False))
428 # Example: http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706
429 elif '.asf' in stream_url:
430 asx = self._download_xml(
431 stream_url, video_id,
432 'Downloading stream %d ASX playlist' % num,
433 transform_source=fix_xml_ampersands, fatal=False)
434 if not asx:
435 continue
436 ref = asx.find('./ENTRY/Ref')
437 if ref is None:
438 continue
439 video_url = ref.get('href')
440 if not video_url or video_url in urls:
441 continue
442 urls.add(video_url)
443 formats.append({
444 'url': video_url,
445 'ext': stream.get('formaat', 'asf'),
446 'quality': stream.get('kwaliteit'),
447 'preference': -10,
448 })
449 else:
450 formats.append({
451 'url': stream_url,
452 'quality': stream.get('kwaliteit'),
453 })
454
455 subtitles = {}
456 if metadata.get('tt888') == 'ja':
457 subtitles['nl'] = [{
458 'ext': 'vtt',
459 'url': 'http://tt888.omroep.nl/tt888/%s' % video_id,
460 }]
461
462 return {
463 'id': video_id,
464 'title': title,
465 'description': metadata.get('info'),
466 'thumbnail': metadata.get('images', [{'url': None}])[-1]['url'],
467 'upload_date': unified_strdate(metadata.get('gidsdatum')),
468 'duration': parse_duration(metadata.get('tijdsduur')),
469 'formats': formats,
470 'subtitles': subtitles,
471 'is_live': is_live,
472 }
473
474
475 class NPOLiveIE(NPOBaseIE):
476 IE_NAME = 'npo.nl:live'
477 _VALID_URL = r'https?://(?:www\.)?npo(?:start)?\.nl/live(?:/(?P<id>[^/?#&]+))?'
478
479 _TESTS = [{
480 'url': 'http://www.npo.nl/live/npo-1',
481 'info_dict': {
482 'id': 'LI_NL1_4188102',
483 'display_id': 'npo-1',
484 'ext': 'mp4',
485 'title': 're:^NPO 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
486 'is_live': True,
487 },
488 'params': {
489 'skip_download': True,
490 }
491 }, {
492 'url': 'http://www.npo.nl/live',
493 'only_matching': True,
494 }, {
495 'url': 'https://www.npostart.nl/live/npo-1',
496 'only_matching': True,
497 }]
498
499 def _real_extract(self, url):
500 display_id = self._match_id(url) or 'npo-1'
501
502 webpage = self._download_webpage(url, display_id)
503
504 live_id = self._search_regex(
505 [r'media-id="([^"]+)"', r'data-prid="([^"]+)"'], webpage, 'live id')
506
507 return {
508 '_type': 'url_transparent',
509 'url': 'npo:%s' % live_id,
510 'ie_key': NPOIE.ie_key(),
511 'id': live_id,
512 'display_id': display_id,
513 }
514
515
516 class NPORadioIE(InfoExtractor):
517 IE_NAME = 'npo.nl:radio'
518 _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/(?P<id>[^/]+)'
519
520 _TEST = {
521 'url': 'http://www.npo.nl/radio/radio-1',
522 'info_dict': {
523 'id': 'radio-1',
524 'ext': 'mp3',
525 'title': 're:^NPO Radio 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
526 'is_live': True,
527 },
528 'params': {
529 'skip_download': True,
530 }
531 }
532
533 @classmethod
534 def suitable(cls, url):
535 return False if NPORadioFragmentIE.suitable(url) else super(NPORadioIE, cls).suitable(url)
536
537 @staticmethod
538 def _html_get_attribute_regex(attribute):
539 return r'{0}\s*=\s*\'([^\']+)\''.format(attribute)
540
541 def _real_extract(self, url):
542 video_id = self._match_id(url)
543
544 webpage = self._download_webpage(url, video_id)
545
546 title = self._html_search_regex(
547 self._html_get_attribute_regex('data-channel'), webpage, 'title')
548
549 stream = self._parse_json(
550 self._html_search_regex(self._html_get_attribute_regex('data-streams'), webpage, 'data-streams'),
551 video_id)
552
553 codec = stream.get('codec')
554
555 return {
556 'id': video_id,
557 'url': stream['url'],
558 'title': title,
559 'acodec': codec,
560 'ext': codec,
561 'is_live': True,
562 }
563
564
565 class NPORadioFragmentIE(InfoExtractor):
566 IE_NAME = 'npo.nl:radio:fragment'
567 _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/[^/]+/fragment/(?P<id>\d+)'
568
569 _TEST = {
570 'url': 'http://www.npo.nl/radio/radio-5/fragment/174356',
571 'md5': 'dd8cc470dad764d0fdc70a9a1e2d18c2',
572 'info_dict': {
573 'id': '174356',
574 'ext': 'mp3',
575 'title': 'Jubileumconcert Willeke Alberti',
576 },
577 }
578
579 def _real_extract(self, url):
580 audio_id = self._match_id(url)
581
582 webpage = self._download_webpage(url, audio_id)
583
584 title = self._html_search_regex(
585 r'href="/radio/[^/]+/fragment/%s" title="([^"]+)"' % audio_id,
586 webpage, 'title')
587
588 audio_url = self._search_regex(
589 r"data-streams='([^']+)'", webpage, 'audio url')
590
591 return {
592 'id': audio_id,
593 'url': audio_url,
594 'title': title,
595 }
596
597
598 class NPODataMidEmbedIE(InfoExtractor): # XXX: Conventionally, base classes should end with BaseIE/InfoExtractor
599 def _real_extract(self, url):
600 display_id = self._match_id(url)
601 webpage = self._download_webpage(url, display_id)
602 video_id = self._search_regex(
603 r'data-mid=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage, 'video_id', group='id')
604 return {
605 '_type': 'url_transparent',
606 'ie_key': 'NPO',
607 'url': 'npo:%s' % video_id,
608 'display_id': display_id
609 }
610
611
612 class SchoolTVIE(NPODataMidEmbedIE):
613 IE_NAME = 'schooltv'
614 _VALID_URL = r'https?://(?:www\.)?schooltv\.nl/video/(?P<id>[^/?#&]+)'
615
616 _TEST = {
617 'url': 'http://www.schooltv.nl/video/ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam/',
618 'info_dict': {
619 'id': 'WO_NTR_429477',
620 'display_id': 'ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam',
621 'title': 'Ademhaling: De hele dag haal je adem. Maar wat gebeurt er dan eigenlijk in je lichaam?',
622 'ext': 'mp4',
623 'description': 'md5:abfa0ff690adb73fd0297fd033aaa631'
624 },
625 'params': {
626 # Skip because of m3u8 download
627 'skip_download': True
628 }
629 }
630
631
632 class HetKlokhuisIE(NPODataMidEmbedIE):
633 IE_NAME = 'hetklokhuis'
634 _VALID_URL = r'https?://(?:www\.)?hetklokhuis\.nl/[^/]+/\d+/(?P<id>[^/?#&]+)'
635
636 _TEST = {
637 'url': 'http://hetklokhuis.nl/tv-uitzending/3471/Zwaartekrachtsgolven',
638 'info_dict': {
639 'id': 'VPWON_1260528',
640 'display_id': 'Zwaartekrachtsgolven',
641 'ext': 'm4v',
642 'title': 'Het Klokhuis: Zwaartekrachtsgolven',
643 'description': 'md5:c94f31fb930d76c2efa4a4a71651dd48',
644 'upload_date': '20170223',
645 },
646 'params': {
647 'skip_download': True
648 }
649 }
650
651
652 class NPOPlaylistBaseIE(NPOIE): # XXX: Do not subclass from concrete IE
653 def _real_extract(self, url):
654 playlist_id = self._match_id(url)
655
656 webpage = self._download_webpage(url, playlist_id)
657
658 entries = [
659 self.url_result('npo:%s' % video_id if not video_id.startswith('http') else video_id)
660 for video_id in orderedSet(re.findall(self._PLAYLIST_ENTRY_RE, webpage))
661 ]
662
663 playlist_title = self._html_search_regex(
664 self._PLAYLIST_TITLE_RE, webpage, 'playlist title',
665 default=None) or self._og_search_title(webpage)
666
667 return self.playlist_result(entries, playlist_id, playlist_title)
668
669
670 class VPROIE(NPOPlaylistBaseIE):
671 IE_NAME = 'vpro'
672 _VALID_URL = r'https?://(?:www\.)?(?:(?:tegenlicht\.)?vpro|2doc)\.nl/(?:[^/]+/)*(?P<id>[^/]+)\.html'
673 _PLAYLIST_TITLE_RE = (r'<h1[^>]+class=["\'].*?\bmedia-platform-title\b.*?["\'][^>]*>([^<]+)',
674 r'<h5[^>]+class=["\'].*?\bmedia-platform-subtitle\b.*?["\'][^>]*>([^<]+)')
675 _PLAYLIST_ENTRY_RE = r'data-media-id="([^"]+)"'
676
677 _TESTS = [
678 {
679 'url': 'http://tegenlicht.vpro.nl/afleveringen/2012-2013/de-toekomst-komt-uit-afrika.html',
680 'md5': 'f8065e4e5a7824068ed3c7e783178f2c',
681 'info_dict': {
682 'id': 'VPWON_1169289',
683 'ext': 'm4v',
684 'title': 'De toekomst komt uit Afrika',
685 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea',
686 'upload_date': '20130225',
687 },
688 'skip': 'Video gone',
689 },
690 {
691 'url': 'http://www.vpro.nl/programmas/2doc/2015/sergio-herman.html',
692 'info_dict': {
693 'id': 'sergio-herman',
694 'title': 'sergio herman: fucking perfect',
695 },
696 'playlist_count': 2,
697 },
698 {
699 # playlist with youtube embed
700 'url': 'http://www.vpro.nl/programmas/2doc/2015/education-education.html',
701 'info_dict': {
702 'id': 'education-education',
703 'title': 'education education',
704 },
705 'playlist_count': 2,
706 },
707 {
708 'url': 'http://www.2doc.nl/documentaires/series/2doc/2015/oktober/de-tegenprestatie.html',
709 'info_dict': {
710 'id': 'de-tegenprestatie',
711 'title': 'De Tegenprestatie',
712 },
713 'playlist_count': 2,
714 }, {
715 'url': 'http://www.2doc.nl/speel~VARA_101375237~mh17-het-verdriet-van-nederland~.html',
716 'info_dict': {
717 'id': 'VARA_101375237',
718 'ext': 'm4v',
719 'title': 'MH17: Het verdriet van Nederland',
720 'description': 'md5:09e1a37c1fdb144621e22479691a9f18',
721 'upload_date': '20150716',
722 },
723 'params': {
724 # Skip because of m3u8 download
725 'skip_download': True
726 },
727 }
728 ]
729
730
731 class WNLIE(NPOPlaylistBaseIE):
732 IE_NAME = 'wnl'
733 _VALID_URL = r'https?://(?:www\.)?omroepwnl\.nl/video/detail/(?P<id>[^/]+)__\d+'
734 _PLAYLIST_TITLE_RE = r'(?s)<h1[^>]+class="subject"[^>]*>(.+?)</h1>'
735 _PLAYLIST_ENTRY_RE = r'<a[^>]+href="([^"]+)"[^>]+class="js-mid"[^>]*>Deel \d+'
736
737 _TESTS = [{
738 'url': 'http://www.omroepwnl.nl/video/detail/vandaag-de-dag-6-mei__060515',
739 'info_dict': {
740 'id': 'vandaag-de-dag-6-mei',
741 'title': 'Vandaag de Dag 6 mei',
742 },
743 'playlist_count': 4,
744 }]
745
746
747 class AndereTijdenIE(NPOPlaylistBaseIE):
748 IE_NAME = 'anderetijden'
749 _VALID_URL = r'https?://(?:www\.)?anderetijden\.nl/programma/(?:[^/]+/)+(?P<id>[^/?#&]+)'
750 _PLAYLIST_TITLE_RE = r'(?s)<h1[^>]+class=["\'].*?\bpage-title\b.*?["\'][^>]*>(.+?)</h1>'
751 _PLAYLIST_ENTRY_RE = r'<figure[^>]+class=["\']episode-container episode-page["\'][^>]+data-prid=["\'](.+?)["\']'
752
753 _TESTS = [{
754 'url': 'http://anderetijden.nl/programma/1/Andere-Tijden/aflevering/676/Duitse-soldaten-over-de-Slag-bij-Arnhem',
755 'info_dict': {
756 'id': 'Duitse-soldaten-over-de-Slag-bij-Arnhem',
757 'title': 'Duitse soldaten over de Slag bij Arnhem',
758 },
759 'playlist_count': 3,
760 }]