rtlnl.py 5.6 KB

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