4 from .common
import InfoExtractor
5 from ..networking
import HEADRequest
13 get_element_html_by_class
,
14 get_elements_html_by_class
,
26 class BitChuteIE(InfoExtractor
):
27 _VALID_URL
= r
'https?://(?:www\.)?bitchute\.com/(?:video|embed|torrent/[^/]+)/(?P<id>[^/?#&]+)'
28 _EMBED_REGEX
= [rf
'<(?:script|iframe)[^>]+\bsrc=(["\'])(?P<url>{_VALID_URL})']
30 'url': 'https://www.bitchute.com/video/UGlrF9o9b-Q/',
31 'md5': '7e427d7ed7af5a75b5855705ec750e2b',
35 'title': 'This is the first video on #BitChute !',
36 'description': 'md5:a0337e7b1fe39e32336974af8173a034',
37 'thumbnail': r
're:^https?://.*\.jpg$',
38 'uploader': 'BitChute',
39 'upload_date': '20170103',
40 'uploader_url': 'https://www.bitchute.com/profile/I5NgtHZn9vPj/',
41 'channel': 'BitChute',
42 'channel_url': 'https://www.bitchute.com/channel/bitchute/'
45 # test case: video with different channel and uploader
46 'url': 'https://www.bitchute.com/video/Yti_j9A-UZ4/',
47 'md5': 'f10e6a8e787766235946d0868703f1d0',
51 'title': 'Israel at War | Full Measure',
52 'description': 'md5:38cf7bc6f42da1a877835539111c69ef',
53 'thumbnail': r
're:^https?://.*\.jpg$',
54 'uploader': 'sharylattkisson',
55 'upload_date': '20231106',
56 'uploader_url': 'https://www.bitchute.com/profile/9K0kUWA9zmd9/',
57 'channel': 'Full Measure with Sharyl Attkisson',
58 'channel_url': 'https://www.bitchute.com/channel/sharylattkisson/'
61 # video not downloadable in browser, but we can recover it
62 'url': 'https://www.bitchute.com/video/2s6B3nZjAk7R/',
63 'md5': '05c12397d5354bf24494885b08d24ed1',
68 'title': 'STYXHEXENHAMMER666 - Election Fraud, Clinton 2020, EU Armies, and Gun Control',
69 'description': 'md5:228ee93bd840a24938f536aeac9cf749',
70 'thumbnail': r
're:^https?://.*\.jpg$',
71 'uploader': 'BitChute',
72 'upload_date': '20181113',
73 'uploader_url': 'https://www.bitchute.com/profile/I5NgtHZn9vPj/',
74 'channel': 'BitChute',
75 'channel_url': 'https://www.bitchute.com/channel/bitchute/'
77 'params': {'check_formats': None}
,
80 'url': 'https://www.bitchute.com/video/WEnQU7XGcTdl/',
84 'title': 'Impartial Truth - Ein Letzter Appell an die Vernunft',
86 'params': {'skip_download': True}
,
87 'skip': 'Georestricted in DE',
89 'url': 'https://www.bitchute.com/embed/lbb5G1hjPhw/',
90 'only_matching': True,
92 'url': 'https://www.bitchute.com/torrent/Zee5BE49045h/szoMrox2JEI.webtorrent',
93 'only_matching': True,
98 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.57 Safari/537.36',
99 'Referer': 'https://www.bitchute.com/',
102 def _check_format(self
, video_url
, video_id
):
104 re
.sub(r
'(^https?://)(seed\d+)(?=\.bitchute\.com)', fr
'\g<1>{host}', video_url
)
105 for host
in (r
'\g<2>', 'seed122', 'seed125', 'seed126', 'seed128',
106 'seed132', 'seed150', 'seed151', 'seed152', 'seed153',
107 'seed167', 'seed171', 'seed177', 'seed305', 'seed307',
108 'seedp29xb', 'zb10-7gsop1v78'))
111 response
= self
._request
_webpage
(
112 HEADRequest(url
), video_id
=video_id
, note
=f
'Checking {url}', headers
=self
._HEADERS
)
113 except ExtractorError
as e
:
114 self
.to_screen(f
'{video_id}: URL is invalid, skipping: {e.cause}')
118 'filesize': int_or_none(response
.headers
.get('Content-Length'))
121 def _raise_if_restricted(self
, webpage
):
122 page_title
= clean_html(get_element_by_class('page-title', webpage
)) or ''
123 if re
.fullmatch(r
'(?:Channel|Video) Restricted', page_title
):
124 reason
= clean_html(get_element_by_id('page-detail', webpage
)) or page_title
125 self
.raise_geo_restricted(reason
)
129 path
= extract_attributes(get_element_html_by_class('spa', html
) or '').get('href')
130 return urljoin('https://www.bitchute.com', path
)
132 def _real_extract(self
, url
):
133 video_id
= self
._match
_id
(url
)
134 webpage
= self
._download
_webpage
(
135 f
'https://www.bitchute.com/video/{video_id}', video_id
, headers
=self
._HEADERS
)
137 self
._raise
_if
_restricted
(webpage
)
138 publish_date
= clean_html(get_element_by_class('video-publish-date', webpage
))
139 entries
= self
._parse
_html
5_media
_entries
(url
, webpage
, video_id
)
142 for format_
in traverse_obj(entries
, (0, 'formats', ...)):
143 if self
.get_param('check_formats') is not False:
144 format_
.update(self
._check
_format
(format_
.pop('url'), video_id
) or {})
145 if 'url' not in format_
:
147 formats
.append(format_
)
150 self
.raise_no_formats(
151 'Video is unavailable. Please make sure this video is playable in the browser '
152 'before reporting this issue.', expected
=True, video_id
=video_id
)
154 details
= get_element_by_class('details', webpage
) or ''
155 uploader_html
= get_element_html_by_class('creator', details
) or ''
156 channel_html
= get_element_html_by_class('name', details
) or ''
160 'title': self
._html
_extract
_title
(webpage
) or self
._og
_search
_title
(webpage
),
161 'description': self
._og
_search
_description
(webpage
, default
=None),
162 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
163 'uploader': clean_html(uploader_html
),
164 'uploader_url': self
._make
_url
(uploader_html
),
165 'channel': clean_html(channel_html
),
166 'channel_url': self
._make
_url
(channel_html
),
167 'upload_date': unified_strdate(self
._search
_regex
(
168 r
'at \d+:\d+ UTC on (.+?)\.', publish_date
, 'upload date', fatal
=False)),
173 class BitChuteChannelIE(InfoExtractor
):
174 _VALID_URL
= r
'https?://(?:www\.)?bitchute\.com/(?P<type>channel|playlist)/(?P<id>[^/?#&]+)'
176 'url': 'https://www.bitchute.com/channel/bitchute/',
180 'description': 'md5:5329fb3866125afa9446835594a9b138',
184 'md5': '7e427d7ed7af5a75b5855705ec750e2b',
189 'title': 'This is the first video on #BitChute !',
190 'description': 'md5:a0337e7b1fe39e32336974af8173a034',
191 'thumbnail': r
're:^https?://.*\.jpg$',
192 'uploader': 'BitChute',
193 'upload_date': '20170103',
194 'uploader_url': 'https://www.bitchute.com/profile/I5NgtHZn9vPj/',
195 'channel': 'BitChute',
196 'channel_url': 'https://www.bitchute.com/channel/bitchute/',
203 'skip_download': True,
204 'playlist_items': '-1',
207 'url': 'https://www.bitchute.com/playlist/wV9Imujxasw9/',
208 'playlist_mincount': 20,
210 'id': 'wV9Imujxasw9',
211 'title': 'Bruce MacDonald and "The Light of Darkness"',
212 'description': 'md5:747724ef404eebdfc04277714f81863e',
216 _TOKEN
= 'zyG6tQcGPE5swyAEFLqKUwMuMMuF6IO2DZ6ZDQjGfsL0e4dcTLwqkTTul05Jdve7'
220 'container': 'channel-videos-container',
221 'title': 'channel-videos-title',
222 'description': 'channel-videos-text',
225 'container': 'playlist-video',
227 'description': 'description',
233 def _make_url(playlist_id
, playlist_type
):
234 return f
'https://www.bitchute.com/{playlist_type}/{playlist_id}/'
236 def _fetch_page(self
, playlist_id
, playlist_type
, page_num
):
237 playlist_url
= self
._make
_url
(playlist_id
, playlist_type
)
238 data
= self
._download
_json
(
239 f
'{playlist_url}extend/', playlist_id
, f
'Downloading page {page_num}',
240 data
=urlencode_postdata({
241 'csrfmiddlewaretoken': self
._TOKEN
,
243 'offset': page_num
* self
.PAGE_SIZE
,
245 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
246 'Referer': playlist_url
,
247 'X-Requested-With': 'XMLHttpRequest',
248 'Cookie': f
'csrftoken={self._TOKEN}',
250 if not data
.get('success'):
252 classes
= self
.HTML_CLASS_NAMES
[playlist_type
]
253 for video_html
in get_elements_html_by_class(classes
['container'], data
.get('html')):
254 video_id
= self
._search
_regex
(
255 r
'<a\s[^>]*\bhref=["\']/video
/([^
"\'/]+)', video_html, 'video id', default=None)
258 yield self.url_result(
259 f'https://www.bitchute.com/video/{video_id}', BitChuteIE, video_id, url_transparent=True,
260 title=clean_html(get_element_by_class(classes['title'], video_html)),
261 description=clean_html(get_element_by_class(classes['description'], video_html)),
262 duration=parse_duration(get_element_by_class('video-duration', video_html)),
263 view_count=parse_count(clean_html(get_element_by_class('video-views', video_html))))
265 def _real_extract(self, url):
266 playlist_type, playlist_id = self._match_valid_url(url).group('type', 'id')
267 webpage = self._download_webpage(self._make_url(playlist_id, playlist_type), playlist_id)
269 page_func = functools.partial(self._fetch_page, playlist_id, playlist_type)
270 return self.playlist_result(
271 OnDemandPagedList(page_func, self.PAGE_SIZE), playlist_id,
272 title=self._html_extract_title(webpage, default=None),
273 description=self._html_search_meta(
274 ('description', 'og:description', 'twitter:description'), webpage, default=None),
275 playlist_count=int_or_none(self._html_search_regex(
276 r'<span>(\d+)\s+videos?</span>', webpage, 'playlist count', default=None)))