]>
Commit | Line | Data |
---|---|---|
f1d42a83 | 1 | import itertools |
62852977 | 2 | import re |
3 | ||
70c5802b | 4 | from .common import InfoExtractor |
3d2623a8 | 5 | from ..networking.exceptions import HTTPError |
70c5802b | 6 | from ..utils import ( |
839e2a62 M |
7 | ExtractorError, |
8 | UnsupportedError, | |
9 | clean_html, | |
78bc1868 | 10 | determine_ext, |
6994afc0 | 11 | format_field, |
839e2a62 | 12 | get_element_by_class, |
70c5802b | 13 | int_or_none, |
6994afc0 | 14 | join_nonempty, |
839e2a62 | 15 | parse_count, |
70c5802b | 16 | parse_iso8601, |
0d8affc1 | 17 | traverse_obj, |
4e34889f | 18 | unescapeHTML, |
70c5802b | 19 | ) |
20 | ||
21 | ||
22 | class RumbleEmbedIE(InfoExtractor): | |
23 | _VALID_URL = r'https?://(?:www\.)?rumble\.com/embed/(?:[0-9a-z]+\.)?(?P<id>[0-9a-z]+)' | |
bfd973ec | 24 | _EMBED_REGEX = [fr'(?:<(?:script|iframe)[^>]+\bsrc=|["\']embedUrl["\']\s*:\s*)["\'](?P<url>{_VALID_URL})'] |
70c5802b | 25 | _TESTS = [{ |
26 | 'url': 'https://rumble.com/embed/v5pv5f', | |
27 | 'md5': '36a18a049856720189f30977ccbb2c34', | |
28 | 'info_dict': { | |
29 | 'id': 'v5pv5f', | |
30 | 'ext': 'mp4', | |
31 | 'title': 'WMAR 2 News Latest Headlines | October 20, 6pm', | |
32 | 'timestamp': 1571611968, | |
33 | 'upload_date': '20191020', | |
64fa820c | 34 | 'channel_url': 'https://rumble.com/c/WMAR', |
35 | 'channel': 'WMAR', | |
23d829a3 | 36 | 'thumbnail': 'https://sp.rmbl.ws/s8/1/5/M/z/1/5Mz1a.qR4e-small-WMAR-2-News-Latest-Headline.jpg', |
64fa820c | 37 | 'duration': 234, |
38 | 'uploader': 'WMAR', | |
0d8affc1 | 39 | 'live_status': 'not_live', |
70c5802b | 40 | } |
4e34889f | 41 | }, { |
42 | 'url': 'https://rumble.com/embed/vslb7v', | |
43 | 'md5': '7418035de1a30a178b8af34dc2b6a52b', | |
44 | 'info_dict': { | |
45 | 'id': 'vslb7v', | |
46 | 'ext': 'mp4', | |
47 | 'title': 'Defense Sec. says US Commitment to NATO Defense \'Ironclad\'', | |
48 | 'timestamp': 1645142135, | |
49 | 'upload_date': '20220217', | |
50 | 'channel_url': 'https://rumble.com/c/CyberTechNews', | |
51 | 'channel': 'CTNews', | |
52 | 'thumbnail': 'https://sp.rmbl.ws/s8/6/7/i/9/h/7i9hd.OvCc.jpg', | |
53 | 'duration': 901, | |
64fa820c | 54 | 'uploader': 'CTNews', |
0d8affc1 | 55 | 'live_status': 'not_live', |
4e34889f | 56 | } |
0d8affc1 M |
57 | }, { |
58 | 'url': 'https://rumble.com/embed/vunh1h', | |
59 | 'info_dict': { | |
60 | 'id': 'vunh1h', | |
61 | 'ext': 'mp4', | |
62 | 'title': '‘Gideon, op zoek naar de waarheid’ including ENG SUBS', | |
63 | 'timestamp': 1647197663, | |
64 | 'upload_date': '20220313', | |
65 | 'channel_url': 'https://rumble.com/user/BLCKBX', | |
66 | 'channel': 'BLCKBX', | |
67 | 'thumbnail': r're:https://.+\.jpg', | |
68 | 'duration': 5069, | |
69 | 'uploader': 'BLCKBX', | |
70 | 'live_status': 'not_live', | |
71 | 'subtitles': { | |
72 | 'en': [ | |
73 | { | |
74 | 'url': r're:https://.+\.vtt', | |
75 | 'name': 'English', | |
76 | 'ext': 'vtt' | |
77 | } | |
78 | ] | |
79 | }, | |
80 | }, | |
81 | 'params': {'skip_download': True} | |
82 | }, { | |
83 | 'url': 'https://rumble.com/embed/v1essrt', | |
84 | 'info_dict': { | |
85 | 'id': 'v1essrt', | |
86 | 'ext': 'mp4', | |
23d829a3 | 87 | 'title': 'startswith:lofi hip hop radio 📚 - beats to relax/study to', |
0d8affc1 M |
88 | 'timestamp': 1661519399, |
89 | 'upload_date': '20220826', | |
90 | 'channel_url': 'https://rumble.com/c/LofiGirl', | |
91 | 'channel': 'Lofi Girl', | |
92 | 'thumbnail': r're:https://.+\.jpg', | |
0d8affc1 M |
93 | 'uploader': 'Lofi Girl', |
94 | 'live_status': 'is_live', | |
95 | }, | |
96 | 'params': {'skip_download': True} | |
97 | }, { | |
98 | 'url': 'https://rumble.com/embed/v1amumr', | |
99 | 'info_dict': { | |
100 | 'id': 'v1amumr', | |
23d829a3 | 101 | 'ext': 'mp4', |
0d8affc1 M |
102 | 'fps': 60, |
103 | 'title': 'Turning Point USA 2022 Student Action Summit DAY 1 - Rumble Exclusive Live', | |
104 | 'timestamp': 1658518457, | |
105 | 'upload_date': '20220722', | |
106 | 'channel_url': 'https://rumble.com/c/RumbleEvents', | |
107 | 'channel': 'Rumble Events', | |
108 | 'thumbnail': r're:https://.+\.jpg', | |
109 | 'duration': 16427, | |
110 | 'uploader': 'Rumble Events', | |
111 | 'live_status': 'was_live', | |
112 | }, | |
113 | 'params': {'skip_download': True} | |
70c5802b | 114 | }, { |
115 | 'url': 'https://rumble.com/embed/ufe9n.v5pv5f', | |
116 | 'only_matching': True, | |
117 | }] | |
118 | ||
0d8affc1 | 119 | _WEBPAGE_TESTS = [ |
0d8affc1 M |
120 | { |
121 | 'note': 'Rumble JS embed', | |
122 | 'url': 'https://therightscoop.com/what-does-9-plus-1-plus-1-equal-listen-to-this-audio-of-attempted-kavanaugh-assassins-call-and-youll-get-it', | |
123 | 'md5': '4701209ac99095592e73dbba21889690', | |
124 | 'info_dict': { | |
125 | 'id': 'v15eqxl', | |
126 | 'ext': 'mp4', | |
127 | 'channel': 'Mr Producer Media', | |
128 | 'duration': 92, | |
129 | 'title': '911 Audio From The Man Who Wanted To Kill Supreme Court Justice Kavanaugh', | |
130 | 'channel_url': 'https://rumble.com/c/RichSementa', | |
23d829a3 | 131 | 'thumbnail': 'https://sp.rmbl.ws/s8/1/P/j/f/A/PjfAe.qR4e-small-911-Audio-From-The-Man-Who-.jpg', |
0d8affc1 M |
132 | 'timestamp': 1654892716, |
133 | 'uploader': 'Mr Producer Media', | |
134 | 'upload_date': '20220610', | |
135 | 'live_status': 'not_live', | |
136 | } | |
137 | }, | |
138 | ] | |
139 | ||
79e591b5 | 140 | @classmethod |
bfd973ec | 141 | def _extract_embed_urls(cls, url, webpage): |
142 | embeds = tuple(super()._extract_embed_urls(url, webpage)) | |
79e591b5 | 143 | if embeds: |
bfd973ec | 144 | return embeds |
79e591b5 | 145 | return [f'https://rumble.com/embed/{mobj.group("id")}' for mobj in re.finditer( |
0ce1f48b | 146 | r'<script>[^<]*\bRumble\(\s*"play"\s*,\s*{[^}]*[\'"]?video[\'"]?\s*:\s*[\'"](?P<id>[0-9a-z]+)[\'"]', webpage)] |
62852977 | 147 | |
70c5802b | 148 | def _real_extract(self, url): |
149 | video_id = self._match_id(url) | |
150 | video = self._download_json( | |
0d8affc1 M |
151 | 'https://rumble.com/embedJS/u3/', video_id, |
152 | query={'request': 'video', 'ver': 2, 'v': video_id}) | |
153 | ||
154 | sys_msg = traverse_obj(video, ('sys', 'msg')) | |
155 | if sys_msg: | |
156 | self.report_warning(sys_msg, video_id=video_id) | |
157 | ||
158 | if video.get('live') == 0: | |
159 | live_status = 'not_live' if video.get('livestream_has_dvr') is None else 'was_live' | |
160 | elif video.get('live') == 1: | |
161 | live_status = 'is_upcoming' if video.get('livestream_has_dvr') else 'was_live' | |
162 | elif video.get('live') == 2: | |
163 | live_status = 'is_live' | |
164 | else: | |
165 | live_status = None | |
70c5802b | 166 | |
167 | formats = [] | |
0d8affc1 | 168 | for ext, ext_info in (video.get('ua') or {}).items(): |
6994afc0 | 169 | if isinstance(ext_info, dict): |
170 | for height, video_info in ext_info.items(): | |
171 | if not traverse_obj(video_info, ('meta', 'h', {int_or_none})): | |
172 | video_info.setdefault('meta', {})['h'] = height | |
173 | ext_info = ext_info.values() | |
174 | ||
175 | for video_info in ext_info: | |
0d8affc1 M |
176 | meta = video_info.get('meta') or {} |
177 | if not video_info.get('url'): | |
178 | continue | |
179 | if ext == 'hls': | |
180 | if meta.get('live') is True and video.get('live') == 1: | |
181 | live_status = 'post_live' | |
182 | formats.extend(self._extract_m3u8_formats( | |
183 | video_info['url'], video_id, | |
184 | ext='mp4', m3u8_id='hls', fatal=False, live=live_status == 'is_live')) | |
185 | continue | |
78bc1868 | 186 | timeline = ext == 'timeline' |
187 | if timeline: | |
188 | ext = determine_ext(video_info['url']) | |
0d8affc1 M |
189 | formats.append({ |
190 | 'ext': ext, | |
78bc1868 | 191 | 'acodec': 'none' if timeline else None, |
0d8affc1 | 192 | 'url': video_info['url'], |
6994afc0 | 193 | 'format_id': join_nonempty(ext, format_field(meta, 'h', '%sp')), |
78bc1868 | 194 | 'format_note': 'Timeline' if timeline else None, |
195 | 'fps': None if timeline else video.get('fps'), | |
0d8affc1 M |
196 | **traverse_obj(meta, { |
197 | 'tbr': 'bitrate', | |
198 | 'filesize': 'size', | |
199 | 'width': 'w', | |
200 | 'height': 'h', | |
acacb57c | 201 | }, expected_type=lambda x: int(x) or None) |
0d8affc1 | 202 | }) |
70c5802b | 203 | |
92922fe7 F |
204 | subtitles = { |
205 | lang: [{ | |
206 | 'url': sub_info['path'], | |
207 | 'name': sub_info.get('language') or '', | |
208 | }] for lang, sub_info in (video.get('cc') or {}).items() if sub_info.get('path') | |
209 | } | |
210 | ||
70c5802b | 211 | author = video.get('author') or {} |
0d8affc1 M |
212 | thumbnails = traverse_obj(video, ('t', ..., {'url': 'i', 'width': 'w', 'height': 'h'})) |
213 | if not thumbnails and video.get('i'): | |
214 | thumbnails = [{'url': video['i']}] | |
215 | ||
216 | if live_status in {'is_live', 'post_live'}: | |
217 | duration = None | |
218 | else: | |
219 | duration = int_or_none(video.get('duration')) | |
70c5802b | 220 | |
221 | return { | |
222 | 'id': video_id, | |
0d8affc1 | 223 | 'title': unescapeHTML(video.get('title')), |
70c5802b | 224 | 'formats': formats, |
92922fe7 | 225 | 'subtitles': subtitles, |
0d8affc1 | 226 | 'thumbnails': thumbnails, |
70c5802b | 227 | 'timestamp': parse_iso8601(video.get('pubDate')), |
228 | 'channel': author.get('name'), | |
229 | 'channel_url': author.get('url'), | |
0d8affc1 | 230 | 'duration': duration, |
64fa820c | 231 | 'uploader': author.get('name'), |
0d8affc1 | 232 | 'live_status': live_status, |
70c5802b | 233 | } |
f1d42a83 AG |
234 | |
235 | ||
839e2a62 M |
236 | class RumbleIE(InfoExtractor): |
237 | _VALID_URL = r'https?://(?:www\.)?rumble\.com/(?P<id>v(?!ideos)[\w.-]+)[^/]*$' | |
23d829a3 TL |
238 | _EMBED_REGEX = [ |
239 | r'<a class=video-item--a href=(?P<url>/v[\w.-]+\.html)>', | |
240 | r'<a[^>]+class="videostream__link link"[^>]+href=(?P<url>/v[\w.-]+\.html)[^>]*>'] | |
839e2a62 M |
241 | _TESTS = [{ |
242 | 'add_ie': ['RumbleEmbed'], | |
243 | 'url': 'https://rumble.com/vdmum1-moose-the-dog-helps-girls-dig-a-snow-fort.html', | |
244 | 'md5': '53af34098a7f92c4e51cf0bd1c33f009', | |
245 | 'info_dict': { | |
246 | 'id': 'vb0ofn', | |
247 | 'ext': 'mp4', | |
248 | 'timestamp': 1612662578, | |
249 | 'uploader': 'LovingMontana', | |
250 | 'channel': 'LovingMontana', | |
251 | 'upload_date': '20210207', | |
252 | 'title': 'Winter-loving dog helps girls dig a snow fort ', | |
253 | 'description': 'Moose the dog is more than happy to help with digging out this epic snow fort. Great job, Moose!', | |
254 | 'channel_url': 'https://rumble.com/c/c-546523', | |
255 | 'thumbnail': r're:https://.+\.jpg', | |
256 | 'duration': 103, | |
257 | 'like_count': int, | |
23d829a3 | 258 | 'dislike_count': int, |
839e2a62 M |
259 | 'view_count': int, |
260 | 'live_status': 'not_live', | |
261 | } | |
262 | }, { | |
263 | 'url': 'http://www.rumble.com/vDMUM1?key=value', | |
264 | 'only_matching': True, | |
78bc1868 | 265 | }, { |
266 | 'note': 'timeline format', | |
267 | 'url': 'https://rumble.com/v2ea9qb-the-u.s.-cannot-hide-this-in-ukraine-anymore-redacted-with-natali-and-clayt.html', | |
268 | 'md5': '40d61fec6c0945bca3d0e1dc1aa53d79', | |
269 | 'params': {'format': 'wv'}, | |
270 | 'info_dict': { | |
271 | 'id': 'v2bou5f', | |
272 | 'ext': 'mp4', | |
273 | 'uploader': 'Redacted News', | |
274 | 'upload_date': '20230322', | |
275 | 'timestamp': 1679445010, | |
276 | 'title': 'The U.S. CANNOT hide this in Ukraine anymore | Redacted with Natali and Clayton Morris', | |
277 | 'duration': 892, | |
278 | 'channel': 'Redacted News', | |
279 | 'description': 'md5:aaad0c5c3426d7a361c29bdaaced7c42', | |
280 | 'channel_url': 'https://rumble.com/c/Redacted', | |
281 | 'live_status': 'not_live', | |
282 | 'thumbnail': 'https://sp.rmbl.ws/s8/1/d/x/2/O/dx2Oi.qR4e-small-The-U.S.-CANNOT-hide-this-i.jpg', | |
23d829a3 TL |
283 | 'like_count': int, |
284 | 'dislike_count': int, | |
285 | 'view_count': int, | |
78bc1868 | 286 | }, |
6994afc0 | 287 | }, { |
288 | 'url': 'https://rumble.com/v2e7fju-the-covid-twitter-files-drop-protecting-fauci-while-censoring-the-truth-wma.html', | |
289 | 'info_dict': { | |
290 | 'id': 'v2blzyy', | |
291 | 'ext': 'mp4', | |
292 | 'live_status': 'was_live', | |
293 | 'release_timestamp': 1679446804, | |
294 | 'description': 'md5:2ac4908ccfecfb921f8ffa4b30c1e636', | |
295 | 'release_date': '20230322', | |
296 | 'timestamp': 1679445692, | |
297 | 'duration': 4435, | |
298 | 'upload_date': '20230322', | |
299 | 'title': 'The Covid Twitter Files Drop: Protecting Fauci While Censoring The Truth w/Matt Taibbi', | |
300 | 'uploader': 'Kim Iversen', | |
301 | 'channel_url': 'https://rumble.com/c/KimIversen', | |
302 | 'channel': 'Kim Iversen', | |
303 | 'thumbnail': 'https://sp.rmbl.ws/s8/1/6/b/w/O/6bwOi.qR4e-small-The-Covid-Twitter-Files-Dro.jpg', | |
23d829a3 TL |
304 | 'like_count': int, |
305 | 'dislike_count': int, | |
306 | 'view_count': int, | |
6994afc0 | 307 | }, |
839e2a62 M |
308 | }] |
309 | ||
310 | _WEBPAGE_TESTS = [{ | |
311 | 'url': 'https://rumble.com/videos?page=2', | |
23d829a3 | 312 | 'playlist_mincount': 24, |
839e2a62 M |
313 | 'info_dict': { |
314 | 'id': 'videos?page=2', | |
315 | 'title': 'All videos', | |
316 | 'description': 'Browse videos uploaded to Rumble.com', | |
317 | 'age_limit': 0, | |
318 | }, | |
319 | }, { | |
23d829a3 TL |
320 | 'url': 'https://rumble.com/browse/live', |
321 | 'playlist_mincount': 25, | |
839e2a62 | 322 | 'info_dict': { |
23d829a3 TL |
323 | 'id': 'live', |
324 | 'title': 'Browse', | |
839e2a62 M |
325 | 'age_limit': 0, |
326 | }, | |
327 | }, { | |
328 | 'url': 'https://rumble.com/search/video?q=rumble&sort=views', | |
23d829a3 | 329 | 'playlist_mincount': 24, |
839e2a62 M |
330 | 'info_dict': { |
331 | 'id': 'video?q=rumble&sort=views', | |
332 | 'title': 'Search results for: rumble', | |
333 | 'age_limit': 0, | |
334 | }, | |
335 | }] | |
336 | ||
337 | def _real_extract(self, url): | |
338 | page_id = self._match_id(url) | |
339 | webpage = self._download_webpage(url, page_id) | |
340 | url_info = next(RumbleEmbedIE.extract_from_webpage(self._downloader, url, webpage), None) | |
341 | if not url_info: | |
342 | raise UnsupportedError(url) | |
343 | ||
23d829a3 TL |
344 | return { |
345 | '_type': 'url_transparent', | |
346 | 'ie_key': url_info['ie_key'], | |
347 | 'url': url_info['url'], | |
348 | 'release_timestamp': parse_iso8601(self._search_regex( | |
349 | r'(?:Livestream begins|Streamed on):\s+<time datetime="([^"]+)', webpage, 'release date', default=None)), | |
350 | 'view_count': int_or_none(self._search_regex( | |
351 | r'"userInteractionCount"\s*:\s*(\d+)', webpage, 'view count', default=None)), | |
352 | 'like_count': parse_count(self._search_regex( | |
353 | r'<span data-js="rumbles_up_votes">\s*([\d,.KM]+)', webpage, 'like count', default=None)), | |
354 | 'dislike_count': parse_count(self._search_regex( | |
355 | r'<span data-js="rumbles_down_votes">\s*([\d,.KM]+)', webpage, 'dislike count', default=None)), | |
356 | 'description': clean_html(get_element_by_class('media-description', webpage)) | |
357 | } | |
839e2a62 M |
358 | |
359 | ||
f1d42a83 AG |
360 | class RumbleChannelIE(InfoExtractor): |
361 | _VALID_URL = r'(?P<url>https?://(?:www\.)?rumble\.com/(?:c|user)/(?P<id>[^&?#$/]+))' | |
362 | ||
363 | _TESTS = [{ | |
364 | 'url': 'https://rumble.com/c/Styxhexenhammer666', | |
365 | 'playlist_mincount': 1160, | |
366 | 'info_dict': { | |
367 | 'id': 'Styxhexenhammer666', | |
368 | }, | |
369 | }, { | |
370 | 'url': 'https://rumble.com/user/goldenpoodleharleyeuna', | |
0d8affc1 | 371 | 'playlist_mincount': 4, |
f1d42a83 AG |
372 | 'info_dict': { |
373 | 'id': 'goldenpoodleharleyeuna', | |
374 | }, | |
375 | }] | |
376 | ||
377 | def entries(self, url, playlist_id): | |
378 | for page in itertools.count(1): | |
379 | try: | |
380 | webpage = self._download_webpage(f'{url}?page={page}', playlist_id, note='Downloading page %d' % page) | |
381 | except ExtractorError as e: | |
3d2623a8 | 382 | if isinstance(e.cause, HTTPError) and e.cause.status == 404: |
f1d42a83 AG |
383 | break |
384 | raise | |
0023af81 | 385 | for video_url in re.findall(r'class="[^>"]*videostream__link[^>]+href="([^"]+\.html)"', webpage): |
f1d42a83 AG |
386 | yield self.url_result('https://rumble.com' + video_url) |
387 | ||
388 | def _real_extract(self, url): | |
389 | url, playlist_id = self._match_valid_url(url).groups() | |
390 | return self.playlist_result(self.entries(url, playlist_id), playlist_id=playlist_id) |