logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

radioradicale.py (4031B)


  1. from .common import InfoExtractor
  2. from ..utils import url_or_none
  3. from ..utils.traversal import traverse_obj
  4. class RadioRadicaleIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?radioradicale\.it/scheda/(?P<id>[0-9]+)'
  6. _TESTS = [{
  7. 'url': 'https://www.radioradicale.it/scheda/471591',
  8. 'md5': 'eb0fbe43a601f1a361cbd00f3c45af4a',
  9. 'info_dict': {
  10. 'id': '471591',
  11. 'ext': 'mp4',
  12. 'title': 'md5:e8fbb8de57011a3255db0beca69af73d',
  13. 'description': 'md5:5e15a789a2fe4d67da8d1366996e89ef',
  14. 'location': 'Napoli',
  15. 'duration': 2852.0,
  16. 'timestamp': 1459987200,
  17. 'upload_date': '20160407',
  18. 'thumbnail': 'https://www.radioradicale.it/photo400/0/0/9/0/1/00901768.jpg',
  19. },
  20. }, {
  21. 'url': 'https://www.radioradicale.it/scheda/742783/parlamento-riunito-in-seduta-comune-11a-della-xix-legislatura',
  22. 'info_dict': {
  23. 'id': '742783',
  24. 'title': 'Parlamento riunito in seduta comune (11ª della XIX legislatura)',
  25. 'description': '-) Votazione per l\'elezione di un giudice della Corte Costituzionale (nono scrutinio)',
  26. 'location': 'CAMERA',
  27. 'duration': 5868.0,
  28. 'timestamp': 1730246400,
  29. 'upload_date': '20241030',
  30. },
  31. 'playlist': [{
  32. 'md5': 'aa48de55dcc45478e4cd200f299aab7d',
  33. 'info_dict': {
  34. 'id': '742783-0',
  35. 'ext': 'mp4',
  36. 'title': 'Parlamento riunito in seduta comune (11ª della XIX legislatura)',
  37. },
  38. }, {
  39. 'md5': 'be915c189c70ad2920e5810f32260ff5',
  40. 'info_dict': {
  41. 'id': '742783-1',
  42. 'ext': 'mp4',
  43. 'title': 'Parlamento riunito in seduta comune (11ª della XIX legislatura)',
  44. },
  45. }, {
  46. 'md5': 'f0ee4047342baf8ed3128a8417ac5e0a',
  47. 'info_dict': {
  48. 'id': '742783-2',
  49. 'ext': 'mp4',
  50. 'title': 'Parlamento riunito in seduta comune (11ª della XIX legislatura)',
  51. },
  52. }],
  53. }]
  54. def _entries(self, videos_info, page_id):
  55. for idx, video in enumerate(traverse_obj(
  56. videos_info, ('playlist', lambda _, v: v['sources']))):
  57. video_id = f'{page_id}-{idx}'
  58. formats = []
  59. subtitles = {}
  60. for m3u8_url in traverse_obj(video, ('sources', ..., 'src', {url_or_none})):
  61. fmts, subs = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id)
  62. formats.extend(fmts)
  63. self._merge_subtitles(subs, target=subtitles)
  64. for sub in traverse_obj(video, ('subtitles', ..., lambda _, v: url_or_none(v['src']))):
  65. self._merge_subtitles({sub.get('srclang') or 'und': [{
  66. 'url': sub['src'],
  67. 'name': sub.get('label'),
  68. }]}, target=subtitles)
  69. yield {
  70. 'id': video_id,
  71. 'title': video.get('title'),
  72. 'formats': formats,
  73. 'subtitles': subtitles,
  74. }
  75. def _real_extract(self, url):
  76. page_id = self._match_id(url)
  77. webpage = self._download_webpage(url, page_id)
  78. videos_info = self._search_json(
  79. r'jQuery\.extend\(Drupal\.settings\s*,',
  80. webpage, 'videos_info', page_id)['RRscheda']
  81. entries = list(self._entries(videos_info, page_id))
  82. common_info = {
  83. 'id': page_id,
  84. 'title': self._og_search_title(webpage),
  85. 'description': self._og_search_description(webpage),
  86. 'location': videos_info.get('luogo'),
  87. **self._search_json_ld(webpage, page_id),
  88. }
  89. if len(entries) == 1:
  90. return {
  91. **entries[0],
  92. **common_info,
  93. }
  94. return self.playlist_result(entries, multi_video=True, **common_info)