rtvnh.py 1.3 KB

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