]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/bitchute.py
4 from .common
import InfoExtractor
14 class BitChuteIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?bitchute\.com/(?:video|embed|torrent/[^/]+)/(?P<id>[^/?#&]+)'
17 'url': 'https://www.bitchute.com/video/UGlrF9o9b-Q/',
18 'md5': '7e427d7ed7af5a75b5855705ec750e2b',
22 'title': 'This is the first video on #BitChute !',
23 'description': 'md5:a0337e7b1fe39e32336974af8173a034',
24 'thumbnail': r
're:^https?://.*\.jpg$',
25 'uploader': 'BitChute',
26 'upload_date': '20170103',
29 'url': 'https://www.bitchute.com/embed/lbb5G1hjPhw/',
30 'only_matching': True,
32 'url': 'https://www.bitchute.com/torrent/Zee5BE49045h/szoMrox2JEI.webtorrent',
33 'only_matching': True,
37 def _extract_urls(webpage
):
40 for mobj
in re
.finditer(
41 r
'<(?:script|iframe)[^>]+\bsrc=(["\'])(?P
<url
>%s)' % BitChuteIE._VALID_URL,
44 def _real_extract(self, url):
45 video_id = self._match_id(url)
47 webpage = self._download_webpage(
48 'https
://www
.bitchute
.com
/video
/%s' % video_id, video_id, headers={
49 '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',
52 title = self._html_search_regex(
53 (r'<[^
>]+\bid
=["\']video-title[^>]+>([^<]+)', r'<title>([^<]+)'),
54 webpage, 'title', default=None) or self._html_search_meta(
55 'description', webpage, 'title',
56 default=None) or self._og_search_description(webpage)
59 for mobj in re.finditer(
60 r'addWebSeed\s*\(\s*(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1', webpage):
61 format_urls.append(mobj.group('url
'))
62 format_urls.extend(re.findall(r'as=(https?
://[^
&"\']+)', webpage))
66 for format_url in orderedSet(format_urls)]
69 entries = self._parse_html5_media_entries(
70 url, webpage, video_id)
72 error = self._html_search_regex(r'<h1 class="page
-title
">([^<]+)</h1>', webpage, 'error', default='Cannot find video')
73 if error == 'Video Unavailable':
74 raise GeoRestrictedError(error)
75 raise ExtractorError(error)
76 formats = entries[0]['formats']
78 self._check_formats(formats, video_id)
79 self._sort_formats(formats)
81 description = self._html_search_regex(
82 r'(?s)<div\b[^>]+\bclass=["\']full hidden
[^
>]+>(.+?
)</div
>',
83 webpage, 'description
', fatal=False)
84 thumbnail = self._og_search_thumbnail(
85 webpage, default=None) or self._html_search_meta(
86 'twitter
:image
:src
', webpage, 'thumbnail
')
87 uploader = self._html_search_regex(
88 (r'(?s
)<div
class=["\']channel-banner.*?<p\b[^>]+\bclass=["\']name
[^
>]+>(.+?
)</p
>',
89 r'(?s
)<p
\b[^
>]+\bclass
=["\']video-author[^>]+>(.+?)</p>'),
90 webpage, 'uploader', fatal=False)
92 upload_date = unified_strdate(self._search_regex(
93 r'class=["\']video
-publish
-date
[^
>]+>[^
<]+ at \d
+:\d
+ UTC
on (.+?
)\
.',
94 webpage, 'upload date
', fatal=False))
99 'description
': description,
100 'thumbnail
': thumbnail,
101 'uploader
': uploader,
102 'upload_date
': upload_date,
107 class BitChuteChannelIE(InfoExtractor):
108 _VALID_URL = r'https?
://(?
:www\
.)?bitchute\
.com
/channel
/(?P
<id>[^
/?
#&]+)'
110 'url': 'https://www.bitchute.com/channel/victoriaxrave/',
111 'playlist_mincount': 185,
113 'id': 'victoriaxrave',
117 _TOKEN
= 'zyG6tQcGPE5swyAEFLqKUwMuMMuF6IO2DZ6ZDQjGfsL0e4dcTLwqkTTul05Jdve7'
119 def _entries(self
, channel_id
):
120 channel_url
= 'https://www.bitchute.com/channel/%s/' % channel_id
122 for page_num
in itertools
.count(1):
123 data
= self
._download
_json
(
124 '%sextend/' % channel_url
, channel_id
,
125 'Downloading channel page %d' % page_num
,
126 data
=urlencode_postdata({
127 'csrfmiddlewaretoken': self
._TOKEN
,
131 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
132 'Referer': channel_url
,
133 'X-Requested-With': 'XMLHttpRequest',
134 'Cookie': 'csrftoken=%s' % self
._TOKEN
,
136 if data
.get('success') is False:
138 html
= data
.get('html')
141 video_ids
= re
.findall(
142 r
'class=["\']channel
-videos
-image
-container
[^
>]+>\s
*<a
\b[^
>]+\bhref
=["\']/video/([^"\'/]+)',
146 offset += len(video_ids)
147 for video_id in video_ids:
148 yield self.url_result(
149 'https
://www
.bitchute
.com
/video
/%s' % video_id,
150 ie=BitChuteIE.ie_key(), video_id=video_id)
152 def _real_extract(self, url):
153 channel_id = self._match_id(url)
154 return self.playlist_result(
155 self._entries(channel_id), playlist_id=channel_id)