You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import ExtractorError
  5. class RTVNHIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?rtvnh\.nl/video/(?P<id>[0-9]+)'
  7. _TEST = {
  8. 'url': 'http://www.rtvnh.nl/video/131946',
  9. 'md5': '6e1d0ab079e2a00b6161442d3ceacfc1',
  10. 'info_dict': {
  11. 'id': '131946',
  12. 'ext': 'mp4',
  13. 'title': 'Grote zoektocht in zee bij Zandvoort naar vermiste vrouw',
  14. 'thumbnail': 're:^https?:.*\.jpg$'
  15. }
  16. }
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. meta = self._parse_json(self._download_webpage(
  20. 'http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id)
  21. status = meta.get('status')
  22. if status != 200:
  23. raise ExtractorError(
  24. '%s returned error code %d' % (self.IE_NAME, status), expected=True)
  25. formats = self._extract_smil_formats(
  26. 'http://www.rtvnh.nl/video/smil?m=' + video_id, video_id, fatal=False)
  27. for item in meta['source']['fb']:
  28. if item.get('type') == 'hls':
  29. formats.extend(self._extract_m3u8_formats(
  30. item['file'], video_id, ext='mp4', entry_protocol='m3u8_native'))
  31. elif item.get('type') == '':
  32. formats.append({'url': item['file']})
  33. self._sort_formats(formats)
  34. return {
  35. 'id': video_id,
  36. 'title': meta['title'].strip(),
  37. 'thumbnail': meta.get('image'),
  38. 'formats': formats
  39. }