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