rtlnl.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. int_or_none,
  4. parse_duration,
  5. )
  6. class RtlNlIE(InfoExtractor):
  7. IE_NAME = 'rtl.nl'
  8. IE_DESC = 'rtl.nl and rtlxl.nl'
  9. _EMBED_REGEX = [r'<iframe[^>]+?\bsrc=(?P<q1>[\'"])(?P<url>(?:https?:)?//(?:(?:www|static)\.)?rtl\.nl/(?:system/videoplayer/[^"]+(?:video_)?)?embed[^"]+)(?P=q1)']
  10. _VALID_URL = r'''(?x)
  11. https?://(?:(?:www|static)\.)?
  12. (?:
  13. rtlxl\.nl/(?:[^\#]*\#!|programma)/[^/]+/|
  14. rtl\.nl/(?:(?:system/videoplayer/(?:[^/]+/)+(?:video_)?embed\.html|embed)\b.+?\buuid=|video/)|
  15. embed\.rtl\.nl/\#uuid=
  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. # new embed URL schema
  92. 'url': 'https://embed.rtl.nl/#uuid=84ae5571-ac25-4225-ae0c-ef8d9efb2aed/autoplay=false',
  93. 'only_matching': True,
  94. }]
  95. def _real_extract(self, url):
  96. uuid = self._match_id(url)
  97. info = self._download_json(
  98. f'http://www.rtl.nl/system/s4m/vfd/version=2/uuid={uuid}/fmt=adaptive/',
  99. uuid)
  100. material = info['material'][0]
  101. title = info['abstracts'][0]['name']
  102. subtitle = material.get('title')
  103. if subtitle:
  104. title += f' - {subtitle}'
  105. description = material.get('synopsis')
  106. meta = info.get('meta', {})
  107. videopath = material['videopath']
  108. m3u8_url = meta.get('videohost', 'http://manifest.us.rtl.nl') + videopath
  109. formats = self._extract_m3u8_formats(
  110. m3u8_url, uuid, 'mp4', m3u8_id='hls', fatal=False)
  111. thumbnails = []
  112. for p in ('poster_base_url', '"thumb_base_url"'):
  113. if not meta.get(p):
  114. continue
  115. thumbnails.append({
  116. 'url': self._proto_relative_url(meta[p] + uuid),
  117. 'width': int_or_none(self._search_regex(
  118. r'/sz=([0-9]+)', meta[p], 'thumbnail width', fatal=False)),
  119. 'height': int_or_none(self._search_regex(
  120. r'/sz=[0-9]+x([0-9]+)',
  121. meta[p], 'thumbnail height', fatal=False)),
  122. })
  123. return {
  124. 'id': uuid,
  125. 'title': title,
  126. 'formats': formats,
  127. 'timestamp': material['original_date'],
  128. 'description': description,
  129. 'duration': parse_duration(material.get('duration')),
  130. 'thumbnails': thumbnails,
  131. }
  132. class RTLLuBaseIE(InfoExtractor):
  133. _MEDIA_REGEX = {
  134. 'video': r'<rtl-player\s[^>]*\bhls\s*=\s*"([^"]+)',
  135. 'audio': r'<rtl-audioplayer\s[^>]*\bsrc\s*=\s*"([^"]+)',
  136. 'thumbnail': r'<rtl-player\s[^>]*\bposter\s*=\s*"([^"]+)',
  137. }
  138. def get_media_url(self, webpage, video_id, media_type):
  139. return self._search_regex(self._MEDIA_REGEX[media_type], webpage, f'{media_type} url', default=None)
  140. def get_formats_and_subtitles(self, webpage, video_id):
  141. video_url, audio_url = self.get_media_url(webpage, video_id, 'video'), self.get_media_url(webpage, video_id, 'audio')
  142. formats, subtitles = [], {}
  143. if video_url is not None:
  144. formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, video_id)
  145. if audio_url is not None:
  146. formats.append({'url': audio_url, 'ext': 'mp3', 'vcodec': 'none'})
  147. return formats, subtitles
  148. def _real_extract(self, url):
  149. video_id = self._match_id(url)
  150. is_live = video_id in ('live', 'live-2', 'lauschteren')
  151. # TODO: extract comment from https://www.rtl.lu/comments?status=1&order=desc&context=news|article|<video_id>
  152. # we can context from <rtl-comments context=<context> in webpage
  153. webpage = self._download_webpage(url, video_id)
  154. formats, subtitles = self.get_formats_and_subtitles(webpage, video_id)
  155. return {
  156. 'id': video_id,
  157. 'title': self._og_search_title(webpage),
  158. 'description': self._og_search_description(webpage, default=None),
  159. 'formats': formats,
  160. 'subtitles': subtitles,
  161. 'thumbnail': self.get_media_url(webpage, video_id, 'thumbnail') or self._og_search_thumbnail(webpage, default=None),
  162. 'is_live': is_live,
  163. }
  164. class RTLLuTeleVODIE(RTLLuBaseIE):
  165. IE_NAME = 'rtl.lu:tele-vod'
  166. _VALID_URL = r'https?://(?:www\.)?rtl\.lu/(tele/(?P<slug>[\w-]+)/v/|video/)(?P<id>\d+)(\.html)?'
  167. _TESTS = [{
  168. 'url': 'https://www.rtl.lu/tele/de-journal-vun-der-tele/v/3266757.html',
  169. 'info_dict': {
  170. 'id': '3266757',
  171. 'title': 'Informatiounsversammlung Héichwaasser',
  172. 'ext': 'mp4',
  173. 'thumbnail': 'https://replay-assets.rtl.lu/2021/11/16/d3647fc4-470d-11ec-adc2-3a00abd6e90f_00008.jpg',
  174. 'description': 'md5:b1db974408cc858c9fd241812e4a2a14',
  175. },
  176. }, {
  177. 'url': 'https://www.rtl.lu/video/3295215',
  178. 'info_dict': {
  179. 'id': '3295215',
  180. 'title': 'Kulturassisen iwwer d\'Bestandsopnam vum Lëtzebuerger Konscht',
  181. 'ext': 'mp4',
  182. 'thumbnail': 'https://replay-assets.rtl.lu/2022/06/28/0000_3295215_0000.jpg',
  183. 'description': 'md5:85bcd4e0490aa6ec969d9bf16927437b',
  184. },
  185. }]
  186. class RTLLuArticleIE(RTLLuBaseIE):
  187. IE_NAME = 'rtl.lu:article'
  188. _VALID_URL = r'https?://(?:(www|5minutes|today)\.)rtl\.lu/(?:[\w-]+)/(?:[\w-]+)/a/(?P<id>\d+)\.html'
  189. _TESTS = [{
  190. # Audio-only
  191. 'url': 'https://www.rtl.lu/sport/news/a/1934360.html',
  192. 'info_dict': {
  193. 'id': '1934360',
  194. 'ext': 'mp3',
  195. 'thumbnail': 'https://static.rtl.lu/rtl2008.lu/nt/p/2022/06/28/19/e4b37d66ddf00bab4c45617b91a5bb9b.jpeg',
  196. 'description': 'md5:5eab4a2a911c1fff7efc1682a38f9ef7',
  197. 'title': 'md5:40aa85f135578fbd549d3c9370321f99',
  198. },
  199. }, {
  200. # 5minutes
  201. 'url': 'https://5minutes.rtl.lu/espace-frontaliers/frontaliers-en-questions/a/1853173.html',
  202. 'info_dict': {
  203. 'id': '1853173',
  204. 'ext': 'mp4',
  205. 'description': 'md5:ac031da0740e997a5cf4633173634fee',
  206. 'title': 'md5:87e17722ed21af0f24be3243f4ec0c46',
  207. 'thumbnail': 'https://replay-assets.rtl.lu/2022/01/26/screenshot_20220126104933_3274749_12b249833469b0d6e4440a1dec83cdfa.jpg',
  208. },
  209. }, {
  210. # today.lu
  211. 'url': 'https://today.rtl.lu/entertainment/news/a/1936203.html',
  212. 'info_dict': {
  213. 'id': '1936203',
  214. 'ext': 'mp4',
  215. 'title': 'Once Upon A Time...zu Lëtzebuerg: The Three Witches\' Tower',
  216. 'description': 'The witchy theme continues in the latest episode of Once Upon A Time...',
  217. 'thumbnail': 'https://replay-assets.rtl.lu/2022/07/02/screenshot_20220702122859_3290019_412dc5185951b7f6545a4039c8be9235.jpg',
  218. },
  219. }]
  220. class RTLLuLiveIE(RTLLuBaseIE):
  221. _VALID_URL = r'https?://www\.rtl\.lu/(?:tele|radio)/(?P<id>live(?:-\d+)?|lauschteren)'
  222. _TESTS = [{
  223. # Tele:live
  224. 'url': 'https://www.rtl.lu/tele/live',
  225. 'info_dict': {
  226. 'id': 'live',
  227. 'ext': 'mp4',
  228. 'live_status': 'is_live',
  229. 'title': r're:RTL - Télé LIVE \d{4}-\d{2}-\d{2} \d{2}:\d{2}',
  230. 'thumbnail': 'https://static.rtl.lu/livestream/channel1.jpg',
  231. },
  232. }, {
  233. # Tele:live-2
  234. 'url': 'https://www.rtl.lu/tele/live-2',
  235. 'info_dict': {
  236. 'id': 'live-2',
  237. 'ext': 'mp4',
  238. 'live_status': 'is_live',
  239. 'title': r're:RTL - Télé LIVE \d{4}-\d{2}-\d{2} \d{2}:\d{2}',
  240. 'thumbnail': 'https://static.rtl.lu/livestream/channel2.jpg',
  241. },
  242. }, {
  243. # Radio:lauschteren
  244. 'url': 'https://www.rtl.lu/radio/lauschteren',
  245. 'info_dict': {
  246. 'id': 'lauschteren',
  247. 'ext': 'mp4',
  248. 'live_status': 'is_live',
  249. 'title': r're:RTL - Radio LIVE \d{4}-\d{2}-\d{2} \d{2}:\d{2}',
  250. 'thumbnail': 'https://static.rtl.lu/livestream/rtlradiowebtv.jpg',
  251. },
  252. }]
  253. class RTLLuRadioIE(RTLLuBaseIE):
  254. _VALID_URL = r'https?://www\.rtl\.lu/radio/(?:[\w-]+)/s/(?P<id>\d+)(\.html)?'
  255. _TESTS = [{
  256. 'url': 'https://www.rtl.lu/radio/5-vir-12/s/4033058.html',
  257. 'info_dict': {
  258. 'id': '4033058',
  259. 'ext': 'mp3',
  260. 'description': 'md5:f855a4f3e3235393ae47ed1db5d934b9',
  261. 'title': '5 vir 12 - Stau um Stau',
  262. 'thumbnail': 'https://static.rtl.lu/rtlg//2022/06/24/c9c19e5694a14be46a3647a3760e1f62.jpg',
  263. },
  264. }]