mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-12 10:11:07 +01:00
[extractor/bitchute] Better error for geo-restricted videos (#5474)
Authored by: flashdagger
This commit is contained in:
parent
86973308cd
commit
efdc45a6ea
@ -8,6 +8,7 @@
|
|||||||
OnDemandPagedList,
|
OnDemandPagedList,
|
||||||
clean_html,
|
clean_html,
|
||||||
get_element_by_class,
|
get_element_by_class,
|
||||||
|
get_element_by_id,
|
||||||
get_elements_html_by_class,
|
get_elements_html_by_class,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
@ -49,6 +50,16 @@ class BitChuteIE(InfoExtractor):
|
|||||||
'upload_date': '20181113',
|
'upload_date': '20181113',
|
||||||
},
|
},
|
||||||
'params': {'check_formats': None},
|
'params': {'check_formats': None},
|
||||||
|
}, {
|
||||||
|
# restricted video
|
||||||
|
'url': 'https://www.bitchute.com/video/WEnQU7XGcTdl/',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'WEnQU7XGcTdl',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Impartial Truth - Ein Letzter Appell an die Vernunft',
|
||||||
|
},
|
||||||
|
'params': {'skip_download': True},
|
||||||
|
'skip': 'Georestricted in DE',
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.bitchute.com/embed/lbb5G1hjPhw/',
|
'url': 'https://www.bitchute.com/embed/lbb5G1hjPhw/',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
@ -56,6 +67,7 @@ class BitChuteIE(InfoExtractor):
|
|||||||
'url': 'https://www.bitchute.com/torrent/Zee5BE49045h/szoMrox2JEI.webtorrent',
|
'url': 'https://www.bitchute.com/torrent/Zee5BE49045h/szoMrox2JEI.webtorrent',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
_GEO_BYPASS = False
|
||||||
|
|
||||||
_HEADERS = {
|
_HEADERS = {
|
||||||
'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',
|
'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',
|
||||||
@ -78,11 +90,18 @@ def _check_format(self, video_url, video_id):
|
|||||||
'filesize': int_or_none(response.headers.get('Content-Length'))
|
'filesize': int_or_none(response.headers.get('Content-Length'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _raise_if_restricted(self, webpage):
|
||||||
|
page_title = clean_html(get_element_by_class('page-title', webpage)) or ''
|
||||||
|
if re.fullmatch(r'(?:Channel|Video) Restricted', page_title):
|
||||||
|
reason = clean_html(get_element_by_id('page-detail', webpage)) or page_title
|
||||||
|
self.raise_geo_restricted(reason)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(
|
webpage = self._download_webpage(
|
||||||
f'https://www.bitchute.com/video/{video_id}', video_id, headers=self._HEADERS)
|
f'https://www.bitchute.com/video/{video_id}', video_id, headers=self._HEADERS)
|
||||||
|
|
||||||
|
self._raise_if_restricted(webpage)
|
||||||
publish_date = clean_html(get_element_by_class('video-publish-date', webpage))
|
publish_date = clean_html(get_element_by_class('video-publish-date', webpage))
|
||||||
entries = self._parse_html5_media_entries(url, webpage, video_id)
|
entries = self._parse_html5_media_entries(url, webpage, video_id)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user