logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

npo.py (28194B)


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