]>
Commit | Line | Data |
---|---|---|
1 | import re | |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import ( | |
5 | extract_attributes, | |
6 | unified_timestamp, | |
7 | ) | |
8 | ||
9 | ||
10 | class N1InfoAssetIE(InfoExtractor): | |
11 | _VALID_URL = r'https?://best-vod\.umn\.cdn\.united\.cloud/stream\?asset=(?P<id>[^&]+)' | |
12 | _TESTS = [{ | |
13 | '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', | |
14 | 'md5': '28b08b32aeaff2b8562736ccd5a66fe7', | |
15 | 'info_dict': { | |
16 | 'id': 'ljsottomazilirija3060921-n1info-si-worldwide', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'ljsottomazilirija3060921-n1info-si-worldwide', | |
19 | }, | |
20 | }] | |
21 | ||
22 | def _real_extract(self, url): | |
23 | video_id = self._match_id(url) | |
24 | formats = self._extract_m3u8_formats( | |
25 | url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) | |
26 | ||
27 | return { | |
28 | 'id': video_id, | |
29 | 'title': video_id, | |
30 | 'formats': formats, | |
31 | } | |
32 | ||
33 | ||
34 | class N1InfoIIE(InfoExtractor): | |
35 | IE_NAME = 'N1Info:article' | |
36 | _VALID_URL = r'https?://(?:(?:\w+\.)?n1info\.\w+|nova\.rs)/(?:[^/?#]+/){1,2}(?P<id>[^/?#]+)' | |
37 | _TESTS = [{ | |
38 | # Youtube embedded | |
39 | 'url': 'https://rs.n1info.com/sport-klub/tenis/kako-je-djokovic-propustio-istorijsku-priliku-video/', | |
40 | 'md5': '01ddb6646d0fd9c4c7d990aa77fe1c5a', | |
41 | 'info_dict': { | |
42 | 'id': 'L5Hd4hQVUpk', | |
43 | 'ext': 'mp4', | |
44 | 'upload_date': '20210913', | |
45 | 'title': 'Ozmo i USO21, ep. 13: Novak Đoković – Danil Medvedev | Ključevi Poraza, Budućnost | SPORT KLUB TENIS', | |
46 | 'description': 'md5:467f330af1effedd2e290f10dc31bb8e', | |
47 | 'uploader': 'Sport Klub', | |
48 | 'uploader_id': 'sportklub', | |
49 | }, | |
50 | }, { | |
51 | 'url': 'https://rs.n1info.com/vesti/djilas-los-plan-za-metro-nece-resiti-nijedan-saobracajni-problem/', | |
52 | 'info_dict': { | |
53 | 'id': 'bgmetrosot2409zta20210924174316682-n1info-rs-worldwide', | |
54 | 'ext': 'mp4', | |
55 | 'title': 'Đilas: Predlog izgradnje metroa besmislen; SNS odbacuje navode', | |
56 | 'upload_date': '20210924', | |
57 | 'timestamp': 1632481347, | |
58 | }, | |
59 | 'params': { | |
60 | 'skip_download': True, | |
61 | }, | |
62 | }, { | |
63 | 'url': 'https://n1info.si/novice/slovenija/zadnji-dnevi-na-kopaliscu-ilirija-ilirija-ni-umrla-ubili-so-jo/', | |
64 | 'info_dict': { | |
65 | 'id': 'ljsottomazilirija3060921-n1info-si-worldwide', | |
66 | 'ext': 'mp4', | |
67 | 'title': 'Zadnji dnevi na kopališču Ilirija: “Ilirija ni umrla, ubili so jo”', | |
68 | 'timestamp': 1632567630, | |
69 | 'upload_date': '20210925', | |
70 | }, | |
71 | 'params': { | |
72 | 'skip_download': True, | |
73 | }, | |
74 | }, { | |
75 | # Reddit embedded | |
76 | 'url': 'https://ba.n1info.com/lifestyle/vucic-bolji-od-tita-ako-izgubi-ja-cu-da-crknem-jugoslavija-je-gotova/', | |
77 | 'info_dict': { | |
78 | 'id': '2wmfee9eycp71', | |
79 | 'ext': 'mp4', | |
80 | 'title': '"Ako Vučić izgubi izbore, ja ću da crknem, Jugoslavija je gotova"', | |
81 | 'upload_date': '20210924', | |
82 | 'timestamp': 1632448649.0, | |
83 | 'uploader': 'YouLotWhatDontStop', | |
84 | }, | |
85 | 'params': { | |
86 | 'skip_download': True, | |
87 | }, | |
88 | }, { | |
89 | 'url': 'https://nova.rs/vesti/politika/zaklina-tatalovic-ani-brnabic-pricate-lazi-video/', | |
90 | 'info_dict': { | |
91 | 'id': 'tnjganabrnabicizaklinatatalovic100danavladegp-novas-worldwide', | |
92 | 'ext': 'mp4', | |
93 | 'title': 'Žaklina Tatalović Ani Brnabić: Pričate laži (VIDEO)', | |
94 | 'upload_date': '20211102', | |
95 | 'timestamp': 1635861677, | |
96 | }, | |
97 | }, { | |
98 | 'url': 'https://n1info.rs/vesti/cuta-biti-u-kosovskoj-mitrovici-znaci-da-te-docekaju-eksplozivnim-napravama/', | |
99 | 'info_dict': { | |
100 | 'id': '1332368', | |
101 | 'ext': 'mp4', | |
102 | 'title': 'Ćuta: Biti u Kosovskoj Mitrovici znači da te dočekaju eksplozivnim napravama', | |
103 | 'upload_date': '20230620', | |
104 | 'timestamp': 1687290536, | |
105 | 'thumbnail': 'https://cdn.brid.tv/live/partners/26827/snapshot/1332368_th_6492013a8356f_1687290170.jpg', | |
106 | }, | |
107 | }, { | |
108 | 'url': 'https://hr.n1info.com/vijesti/pravobraniteljica-o-ubojstvu-u-zagrebu-radi-se-o-doista-nezapamcenoj-situaciji/', | |
109 | 'only_matching': True, | |
110 | }] | |
111 | ||
112 | def _real_extract(self, url): | |
113 | video_id = self._match_id(url) | |
114 | webpage = self._download_webpage(url, video_id) | |
115 | ||
116 | title = self._html_search_regex(r'<h1[^>]+>(.+?)</h1>', webpage, 'title') | |
117 | timestamp = unified_timestamp(self._html_search_meta('article:published_time', webpage)) | |
118 | plugin_data = self._html_search_meta('BridPlugin', webpage) | |
119 | entries = [] | |
120 | if plugin_data: | |
121 | site_id = self._html_search_regex(r'site:(\d+)', webpage, 'site id') | |
122 | for video_data in re.findall(r'\$bp\("Brid_\d+", (.+)\);', webpage): | |
123 | video_id = self._parse_json(video_data, title)['video'] | |
124 | entries.append({ | |
125 | 'id': video_id, | |
126 | 'title': title, | |
127 | 'timestamp': timestamp, | |
128 | 'thumbnail': self._html_search_meta('thumbnailURL', webpage), | |
129 | 'formats': self._extract_m3u8_formats( | |
130 | f'https://cdn-uc.brid.tv/live/partners/{site_id}/streaming/{video_id}/{video_id}.m3u8', | |
131 | video_id, fatal=False), | |
132 | }) | |
133 | else: | |
134 | # Old player still present in older articles | |
135 | videos = re.findall(r'(?m)(<video[^>]+>)', webpage) | |
136 | for video in videos: | |
137 | video_data = extract_attributes(video) | |
138 | entries.append({ | |
139 | '_type': 'url_transparent', | |
140 | 'url': video_data.get('data-url'), | |
141 | 'id': video_data.get('id'), | |
142 | 'title': title, | |
143 | 'thumbnail': video_data.get('data-thumbnail'), | |
144 | 'timestamp': timestamp, | |
145 | 'ie_key': 'N1InfoAsset', | |
146 | }) | |
147 | ||
148 | embedded_videos = re.findall(r'(<iframe[^>]+>)', webpage) | |
149 | for embedded_video in embedded_videos: | |
150 | video_data = extract_attributes(embedded_video) | |
151 | url = video_data.get('src') or '' | |
152 | if url.startswith('https://www.youtube.com'): | |
153 | entries.append(self.url_result(url, ie='Youtube')) | |
154 | elif url.startswith('https://www.redditmedia.com'): | |
155 | entries.append(self.url_result(url, ie='RedditR')) | |
156 | ||
157 | return { | |
158 | '_type': 'playlist', | |
159 | 'id': video_id, | |
160 | 'title': title, | |
161 | 'timestamp': timestamp, | |
162 | 'entries': entries, | |
163 | } |