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.

62 lines
2.2 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': 'cdbec9f44550763c8afc96050fa747dc',
  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 = []
  26. rtmp_formats = self._extract_smil_formats(
  27. 'http://www.rtvnh.nl/video/smil?m=' + video_id, video_id)
  28. formats.extend(rtmp_formats)
  29. for rtmp_format in rtmp_formats:
  30. rtmp_url = '%s/%s' % (rtmp_format['url'], rtmp_format['play_path'])
  31. rtsp_format = rtmp_format.copy()
  32. del rtsp_format['play_path']
  33. del rtsp_format['ext']
  34. rtsp_format.update({
  35. 'format_id': rtmp_format['format_id'].replace('rtmp', 'rtsp'),
  36. 'url': rtmp_url.replace('rtmp://', 'rtsp://'),
  37. 'protocol': 'rtsp',
  38. })
  39. formats.append(rtsp_format)
  40. http_base_url = rtmp_url.replace('rtmp://', 'http://')
  41. formats.extend(self._extract_m3u8_formats(
  42. http_base_url + '/playlist.m3u8', video_id, 'mp4',
  43. 'm3u8_native', m3u8_id='hls', fatal=False))
  44. formats.extend(self._extract_f4m_formats(
  45. http_base_url + '/manifest.f4m',
  46. video_id, f4m_id='hds', fatal=False))
  47. self._sort_formats(formats)
  48. return {
  49. 'id': video_id,
  50. 'title': meta['title'].strip(),
  51. 'thumbnail': meta.get('image'),
  52. 'formats': formats
  53. }