n1.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. unified_timestamp,
  5. extract_attributes,
  6. )
  7. class N1InfoAssetIE(InfoExtractor):
  8. _VALID_URL = r'https?://best-vod\.umn\.cdn\.united\.cloud/stream\?asset=(?P<id>[^&]+)'
  9. _TESTS = [{
  10. 'url': 'https://best-vod.umn.cdn.united.cloud/stream?asset=ljsottomazilirija3060921-n1info-si-worldwide&stream=hp1400&t=0&player=m3u8v&sp=n1info&u=n1info&p=n1Sh4redSecre7iNf0',
  11. 'md5': '28b08b32aeaff2b8562736ccd5a66fe7',
  12. 'info_dict': {
  13. 'id': 'ljsottomazilirija3060921-n1info-si-worldwide',
  14. 'ext': 'mp4',
  15. 'title': 'ljsottomazilirija3060921-n1info-si-worldwide',
  16. }
  17. }]
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. formats = self._extract_m3u8_formats(
  21. url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
  22. return {
  23. 'id': video_id,
  24. 'title': video_id,
  25. 'formats': formats,
  26. }
  27. class N1InfoIIE(InfoExtractor):
  28. IE_NAME = 'N1Info:article'
  29. _VALID_URL = r'https?://(?:(?:(?:ba|rs|hr)\.)?n1info\.(?:com|si)|nova\.rs)/(?:[^/]+/){1,2}(?P<id>[^/]+)'
  30. _TESTS = [{
  31. # Youtube embedded
  32. 'url': 'https://rs.n1info.com/sport-klub/tenis/kako-je-djokovic-propustio-istorijsku-priliku-video/',
  33. 'md5': '01ddb6646d0fd9c4c7d990aa77fe1c5a',
  34. 'info_dict': {
  35. 'id': 'L5Hd4hQVUpk',
  36. 'ext': 'mp4',
  37. 'upload_date': '20210913',
  38. 'title': 'Ozmo i USO21, ep. 13: Novak Đoković – Danil Medvedev | Ključevi Poraza, Budućnost | SPORT KLUB TENIS',
  39. 'description': 'md5:467f330af1effedd2e290f10dc31bb8e',
  40. 'uploader': 'Sport Klub',
  41. 'uploader_id': 'sportklub',
  42. }
  43. }, {
  44. 'url': 'https://rs.n1info.com/vesti/djilas-los-plan-za-metro-nece-resiti-nijedan-saobracajni-problem/',
  45. 'info_dict': {
  46. 'id': 'bgmetrosot2409zta20210924174316682-n1info-rs-worldwide',
  47. 'ext': 'mp4',
  48. 'title': 'Đilas: Predlog izgradnje metroa besmislen; SNS odbacuje navode',
  49. 'upload_date': '20210924',
  50. 'timestamp': 1632481347,
  51. },
  52. 'params': {
  53. 'skip_download': True,
  54. },
  55. }, {
  56. 'url': 'https://n1info.si/novice/slovenija/zadnji-dnevi-na-kopaliscu-ilirija-ilirija-ni-umrla-ubili-so-jo/',
  57. 'info_dict': {
  58. 'id': 'ljsottomazilirija3060921-n1info-si-worldwide',
  59. 'ext': 'mp4',
  60. 'title': 'Zadnji dnevi na kopališču Ilirija: “Ilirija ni umrla, ubili so jo”',
  61. 'timestamp': 1632567630,
  62. 'upload_date': '20210925',
  63. },
  64. 'params': {
  65. 'skip_download': True,
  66. },
  67. }, {
  68. # Reddit embedded
  69. 'url': 'https://ba.n1info.com/lifestyle/vucic-bolji-od-tita-ako-izgubi-ja-cu-da-crknem-jugoslavija-je-gotova/',
  70. 'info_dict': {
  71. 'id': '2wmfee9eycp71',
  72. 'ext': 'mp4',
  73. 'title': '"Ako Vučić izgubi izbore, ja ću da crknem, Jugoslavija je gotova"',
  74. 'upload_date': '20210924',
  75. 'timestamp': 1632448649.0,
  76. 'uploader': 'YouLotWhatDontStop',
  77. },
  78. 'params': {
  79. 'skip_download': True,
  80. },
  81. }, {
  82. 'url': 'https://nova.rs/vesti/politika/zaklina-tatalovic-ani-brnabic-pricate-lazi-video/',
  83. 'info_dict': {
  84. 'id': 'tnjganabrnabicizaklinatatalovic100danavladegp-novas-worldwide',
  85. 'ext': 'mp4',
  86. 'title': 'Žaklina Tatalović Ani Brnabić: Pričate laži (VIDEO)',
  87. 'upload_date': '20211102',
  88. 'timestamp': 1635861677,
  89. },
  90. }, {
  91. 'url': 'https://hr.n1info.com/vijesti/pravobraniteljica-o-ubojstvu-u-zagrebu-radi-se-o-doista-nezapamcenoj-situaciji/',
  92. 'only_matching': True,
  93. }]
  94. def _real_extract(self, url):
  95. video_id = self._match_id(url)
  96. webpage = self._download_webpage(url, video_id)
  97. title = self._html_search_regex(r'<h1[^>]+>(.+?)</h1>', webpage, 'title')
  98. timestamp = unified_timestamp(self._html_search_meta('article:published_time', webpage))
  99. videos = re.findall(r'(?m)(<video[^>]+>)', webpage)
  100. entries = []
  101. for video in videos:
  102. video_data = extract_attributes(video)
  103. entries.append({
  104. '_type': 'url_transparent',
  105. 'url': video_data.get('data-url'),
  106. 'id': video_data.get('id'),
  107. 'title': title,
  108. 'thumbnail': video_data.get('data-thumbnail'),
  109. 'timestamp': timestamp,
  110. 'ie_key': 'N1InfoAsset'})
  111. embedded_videos = re.findall(r'(<iframe[^>]+>)', webpage)
  112. for embedded_video in embedded_videos:
  113. video_data = extract_attributes(embedded_video)
  114. url = video_data.get('src') or ''
  115. if url.startswith('https://www.youtube.com'):
  116. entries.append(self.url_result(url, ie='Youtube'))
  117. elif url.startswith('https://www.redditmedia.com'):
  118. entries.append(self.url_result(url, ie='RedditR'))
  119. return {
  120. '_type': 'playlist',
  121. 'id': video_id,
  122. 'title': title,
  123. 'timestamp': timestamp,
  124. 'entries': entries,
  125. }