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.

71 lines
2.3 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import parse_duration
  5. class RtlXlIE(InfoExtractor):
  6. IE_NAME = 'rtlxl.nl'
  7. _VALID_URL = r'https?://(www\.)?rtlxl\.nl/#!/[^/]+/(?P<uuid>[^/?]+)'
  8. _TEST = {
  9. 'url': 'http://www.rtlxl.nl/#!/rtl-nieuws-132237/6e4203a6-0a5e-3596-8424-c599a59e0677',
  10. 'md5': 'cc16baa36a6c169391f0764fa6b16654',
  11. 'info_dict': {
  12. 'id': '6e4203a6-0a5e-3596-8424-c599a59e0677',
  13. 'ext': 'mp4',
  14. 'title': 'RTL Nieuws - Laat',
  15. 'description': 'md5:6b61f66510c8889923b11f2778c72dc5',
  16. 'timestamp': 1408051800,
  17. 'upload_date': '20140814',
  18. 'duration': 576.880,
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. uuid = mobj.group('uuid')
  24. info = self._download_json(
  25. 'http://www.rtl.nl/system/s4m/vfd/version=2/uuid=%s/fmt=flash/' % uuid,
  26. uuid)
  27. material = info['material'][0]
  28. episode_info = info['episodes'][0]
  29. progname = info['abstracts'][0]['name']
  30. subtitle = material['title'] or info['episodes'][0]['name']
  31. # Use unencrypted m3u8 streams (See https://github.com/rg3/youtube-dl/issues/4118)
  32. videopath = material['videopath'].replace('.f4m', '.m3u8')
  33. m3u8_url = 'http://manifest.us.rtl.nl' + videopath
  34. formats = self._extract_m3u8_formats(m3u8_url, uuid, ext='mp4')
  35. video_urlpart = videopath.split('/flash/')[1][:-5]
  36. PG_URL_TEMPLATE = 'http://pg.us.rtl.nl/rtlxl/network/%s/progressive/%s.mp4'
  37. formats.extend([
  38. {
  39. 'url': PG_URL_TEMPLATE % ('a2m', video_urlpart),
  40. 'format_id': 'pg-sd',
  41. },
  42. {
  43. 'url': PG_URL_TEMPLATE % ('a3m', video_urlpart),
  44. 'format_id': 'pg-hd',
  45. 'quality': 0,
  46. }
  47. ])
  48. self._sort_formats(formats)
  49. return {
  50. 'id': uuid,
  51. 'title': '%s - %s' % (progname, subtitle),
  52. 'formats': formats,
  53. 'timestamp': material['original_date'],
  54. 'description': episode_info['synopsis'],
  55. 'duration': parse_duration(material.get('duration')),
  56. }