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.

138 lines
5.5 KiB

9 years ago
9 years ago
9 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. parse_duration,
  7. )
  8. class RtlNlIE(InfoExtractor):
  9. IE_NAME = 'rtl.nl'
  10. IE_DESC = 'rtl.nl and rtlxl.nl'
  11. _VALID_URL = r'''(?x)
  12. https?://(?:www\.)?
  13. (?:
  14. rtlxl\.nl/\#!/[^/]+/|
  15. rtl\.nl/system/videoplayer/(?:[^/]+/)+(?:video_)?embed\.html\b.+?\buuid=
  16. )
  17. (?P<id>[0-9a-f-]+)'''
  18. _TESTS = [{
  19. 'url': 'http://www.rtlxl.nl/#!/rtl-nieuws-132237/6e4203a6-0a5e-3596-8424-c599a59e0677',
  20. 'md5': 'cc16baa36a6c169391f0764fa6b16654',
  21. 'info_dict': {
  22. 'id': '6e4203a6-0a5e-3596-8424-c599a59e0677',
  23. 'ext': 'mp4',
  24. 'title': 'RTL Nieuws - Laat',
  25. 'description': 'md5:6b61f66510c8889923b11f2778c72dc5',
  26. 'timestamp': 1408051800,
  27. 'upload_date': '20140814',
  28. 'duration': 576.880,
  29. },
  30. }, {
  31. 'url': 'http://www.rtl.nl/system/videoplayer/derden/rtlnieuws/video_embed.html#uuid=84ae5571-ac25-4225-ae0c-ef8d9efb2aed/autoplay=false',
  32. 'md5': 'dea7474214af1271d91ef332fb8be7ea',
  33. 'info_dict': {
  34. 'id': '84ae5571-ac25-4225-ae0c-ef8d9efb2aed',
  35. 'ext': 'mp4',
  36. 'timestamp': 1424039400,
  37. 'title': 'RTL Nieuws - Nieuwe beelden Kopenhagen: chaos direct na aanslag',
  38. 'thumbnail': 're:^https?://screenshots\.rtl\.nl/system/thumb/sz=[0-9]+x[0-9]+/uuid=84ae5571-ac25-4225-ae0c-ef8d9efb2aed$',
  39. 'upload_date': '20150215',
  40. 'description': 'Er zijn nieuwe beelden vrijgegeven die vlak na de aanslag in Kopenhagen zijn gemaakt. Op de video is goed te zien hoe omstanders zich bekommeren om één van de slachtoffers, terwijl de eerste agenten ter plaatse komen.',
  41. }
  42. }, {
  43. # empty synopsis and missing episodes (see https://github.com/rg3/youtube-dl/issues/6275)
  44. 'url': 'http://www.rtl.nl/system/videoplayer/derden/rtlnieuws/video_embed.html#uuid=f536aac0-1dc3-4314-920e-3bd1c5b3811a/autoplay=false',
  45. 'info_dict': {
  46. 'id': 'f536aac0-1dc3-4314-920e-3bd1c5b3811a',
  47. 'ext': 'mp4',
  48. 'title': 'RTL Nieuws - Meer beelden van overval juwelier',
  49. 'thumbnail': 're:^https?://screenshots\.rtl\.nl/system/thumb/sz=[0-9]+x[0-9]+/uuid=f536aac0-1dc3-4314-920e-3bd1c5b3811a$',
  50. 'timestamp': 1437233400,
  51. 'upload_date': '20150718',
  52. 'duration': 30.474,
  53. },
  54. 'params': {
  55. 'skip_download': True,
  56. },
  57. }, {
  58. # encrypted m3u8 streams, georestricted
  59. 'url': 'http://www.rtlxl.nl/#!/afl-2-257632/52a74543-c504-4cde-8aa8-ec66fe8d68a7',
  60. 'only_matching': True,
  61. }, {
  62. 'url': 'http://www.rtl.nl/system/videoplayer/derden/embed.html#!/uuid=bb0353b0-d6a4-1dad-90e9-18fe75b8d1f0',
  63. 'only_matching': True,
  64. }]
  65. def _real_extract(self, url):
  66. uuid = self._match_id(url)
  67. info = self._download_json(
  68. 'http://www.rtl.nl/system/s4m/vfd/version=2/uuid=%s/fmt=adaptive/' % uuid,
  69. uuid)
  70. material = info['material'][0]
  71. title = info['abstracts'][0]['name']
  72. subtitle = material.get('title')
  73. if subtitle:
  74. title += ' - %s' % subtitle
  75. description = material.get('synopsis')
  76. meta = info.get('meta', {})
  77. # m3u8 streams are encrypted and may not be handled properly by older ffmpeg/avconv.
  78. # To workaround this previously adaptive -> flash trick was used to obtain
  79. # unencrypted m3u8 streams (see https://github.com/rg3/youtube-dl/issues/4118)
  80. # and bypass georestrictions as well.
  81. # Currently, unencrypted m3u8 playlists are (intentionally?) invalid and therefore
  82. # unusable albeit can be fixed by simple string replacement (see
  83. # https://github.com/rg3/youtube-dl/pull/6337)
  84. # Since recent ffmpeg and avconv handle encrypted streams just fine encrypted
  85. # streams are used now.
  86. videopath = material['videopath']
  87. m3u8_url = meta.get('videohost', 'http://manifest.us.rtl.nl') + videopath
  88. formats = self._extract_m3u8_formats(m3u8_url, uuid, ext='mp4')
  89. video_urlpart = videopath.split('/adaptive/')[1][:-5]
  90. PG_URL_TEMPLATE = 'http://pg.us.rtl.nl/rtlxl/network/%s/progressive/%s.mp4'
  91. formats.extend([
  92. {
  93. 'url': PG_URL_TEMPLATE % ('a2m', video_urlpart),
  94. 'format_id': 'pg-sd',
  95. },
  96. {
  97. 'url': PG_URL_TEMPLATE % ('a3m', video_urlpart),
  98. 'format_id': 'pg-hd',
  99. 'quality': 0,
  100. }
  101. ])
  102. self._sort_formats(formats)
  103. thumbnails = []
  104. for p in ('poster_base_url', '"thumb_base_url"'):
  105. if not meta.get(p):
  106. continue
  107. thumbnails.append({
  108. 'url': self._proto_relative_url(meta[p] + uuid),
  109. 'width': int_or_none(self._search_regex(
  110. r'/sz=([0-9]+)', meta[p], 'thumbnail width', fatal=False)),
  111. 'height': int_or_none(self._search_regex(
  112. r'/sz=[0-9]+x([0-9]+)',
  113. meta[p], 'thumbnail height', fatal=False))
  114. })
  115. return {
  116. 'id': uuid,
  117. 'title': title,
  118. 'formats': formats,
  119. 'timestamp': material['original_date'],
  120. 'description': description,
  121. 'duration': parse_duration(material.get('duration')),
  122. 'thumbnails': thumbnails,
  123. }