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.

126 lines
5.0 KiB

10 years ago
10 years ago
10 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|static)\.)?
  13. (?:
  14. rtlxl\.nl/[^\#]*\#!/[^/]+/|
  15. rtl\.nl/(?:(?:system/videoplayer/(?:[^/]+/)+(?:video_)?embed\.html|embed)\b.+?\buuid=|video/)
  16. )
  17. (?P<id>[0-9a-f-]+)'''
  18. _TESTS = [{
  19. 'url': 'http://www.rtlxl.nl/#!/rtl-nieuws-132237/82b1aad1-4a14-3d7b-b554-b0aed1b2c416',
  20. 'md5': '473d1946c1fdd050b2c0161a4b13c373',
  21. 'info_dict': {
  22. 'id': '82b1aad1-4a14-3d7b-b554-b0aed1b2c416',
  23. 'ext': 'mp4',
  24. 'title': 'RTL Nieuws',
  25. 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
  26. 'timestamp': 1461951000,
  27. 'upload_date': '20160429',
  28. 'duration': 1167.96,
  29. },
  30. }, {
  31. # best format avaialble a3t
  32. 'url': 'http://www.rtl.nl/system/videoplayer/derden/rtlnieuws/video_embed.html#uuid=84ae5571-ac25-4225-ae0c-ef8d9efb2aed/autoplay=false',
  33. 'md5': 'dea7474214af1271d91ef332fb8be7ea',
  34. 'info_dict': {
  35. 'id': '84ae5571-ac25-4225-ae0c-ef8d9efb2aed',
  36. 'ext': 'mp4',
  37. 'timestamp': 1424039400,
  38. 'title': 'RTL Nieuws - Nieuwe beelden Kopenhagen: chaos direct na aanslag',
  39. 'thumbnail': r're:^https?://screenshots\.rtl\.nl/(?:[^/]+/)*sz=[0-9]+x[0-9]+/uuid=84ae5571-ac25-4225-ae0c-ef8d9efb2aed$',
  40. 'upload_date': '20150215',
  41. '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.',
  42. }
  43. }, {
  44. # empty synopsis and missing episodes (see https://github.com/rg3/youtube-dl/issues/6275)
  45. # best format available nettv
  46. 'url': 'http://www.rtl.nl/system/videoplayer/derden/rtlnieuws/video_embed.html#uuid=f536aac0-1dc3-4314-920e-3bd1c5b3811a/autoplay=false',
  47. 'info_dict': {
  48. 'id': 'f536aac0-1dc3-4314-920e-3bd1c5b3811a',
  49. 'ext': 'mp4',
  50. 'title': 'RTL Nieuws - Meer beelden van overval juwelier',
  51. 'thumbnail': r're:^https?://screenshots\.rtl\.nl/(?:[^/]+/)*sz=[0-9]+x[0-9]+/uuid=f536aac0-1dc3-4314-920e-3bd1c5b3811a$',
  52. 'timestamp': 1437233400,
  53. 'upload_date': '20150718',
  54. 'duration': 30.474,
  55. },
  56. 'params': {
  57. 'skip_download': True,
  58. },
  59. }, {
  60. # encrypted m3u8 streams, georestricted
  61. 'url': 'http://www.rtlxl.nl/#!/afl-2-257632/52a74543-c504-4cde-8aa8-ec66fe8d68a7',
  62. 'only_matching': True,
  63. }, {
  64. 'url': 'http://www.rtl.nl/system/videoplayer/derden/embed.html#!/uuid=bb0353b0-d6a4-1dad-90e9-18fe75b8d1f0',
  65. 'only_matching': True,
  66. }, {
  67. 'url': 'http://rtlxl.nl/?_ga=1.204735956.572365465.1466978370#!/rtl-nieuws-132237/3c487912-023b-49ac-903e-2c5d79f8410f',
  68. 'only_matching': True,
  69. }, {
  70. 'url': 'https://www.rtl.nl/video/c603c9c2-601d-4b5e-8175-64f1e942dc7d/',
  71. 'only_matching': True,
  72. }, {
  73. 'url': 'https://static.rtl.nl/embed/?uuid=1a2970fc-5c0b-43ff-9fdc-927e39e6d1bc&autoplay=false&publicatiepunt=rtlnieuwsnl',
  74. 'only_matching': True,
  75. }]
  76. def _real_extract(self, url):
  77. uuid = self._match_id(url)
  78. info = self._download_json(
  79. 'http://www.rtl.nl/system/s4m/vfd/version=2/uuid=%s/fmt=adaptive/' % uuid,
  80. uuid)
  81. material = info['material'][0]
  82. title = info['abstracts'][0]['name']
  83. subtitle = material.get('title')
  84. if subtitle:
  85. title += ' - %s' % subtitle
  86. description = material.get('synopsis')
  87. meta = info.get('meta', {})
  88. videopath = material['videopath']
  89. m3u8_url = meta.get('videohost', 'http://manifest.us.rtl.nl') + videopath
  90. formats = self._extract_m3u8_formats(
  91. m3u8_url, uuid, 'mp4', m3u8_id='hls', fatal=False)
  92. self._sort_formats(formats)
  93. thumbnails = []
  94. for p in ('poster_base_url', '"thumb_base_url"'):
  95. if not meta.get(p):
  96. continue
  97. thumbnails.append({
  98. 'url': self._proto_relative_url(meta[p] + uuid),
  99. 'width': int_or_none(self._search_regex(
  100. r'/sz=([0-9]+)', meta[p], 'thumbnail width', fatal=False)),
  101. 'height': int_or_none(self._search_regex(
  102. r'/sz=[0-9]+x([0-9]+)',
  103. meta[p], 'thumbnail height', fatal=False))
  104. })
  105. return {
  106. 'id': uuid,
  107. 'title': title,
  108. 'formats': formats,
  109. 'timestamp': material['original_date'],
  110. 'description': description,
  111. 'duration': parse_duration(material.get('duration')),
  112. 'thumbnails': thumbnails,
  113. }