mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-07-02 16:28:52 +00:00
Compare commits
No commits in common. "942aaf9c2904e0271c299f66ac0e90a30d360f38" and "260c331cc7d4e6d8c21d0d2263e8f64c293bbf09" have entirely different histories.
942aaf9c29
...
260c331cc7
@ -4,7 +4,6 @@ import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..networking import HEADRequest
|
||||
from ..networking.exceptions import HTTPError
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
OnDemandPagedList,
|
||||
@ -93,6 +92,28 @@ class BitChuteIE(InfoExtractor):
|
||||
'timestamp': 1542130287,
|
||||
},
|
||||
'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',
|
||||
'description': 'md5:e7e8390ab79d2c84f3f5d068ed333535',
|
||||
'uploader': 'Freier_Mann',
|
||||
'uploader_id': 'OBhKX1Ss0jyL',
|
||||
'uploader_url': 'https://www.bitchute.com/profile/OBhKX1Ss0jyL/',
|
||||
'channel': 'Der Freie',
|
||||
'channel_id': 'dV8xxWKIxSVU',
|
||||
'channel_url': 'https://www.bitchute.com/channel/freier_mann/',
|
||||
'view_count': int,
|
||||
'duration': 4806.0,
|
||||
'thumbnail': r're:https?://.+/.+\.jpg$',
|
||||
'timestamp': 1609918804,
|
||||
'upload_date': '20210106',
|
||||
},
|
||||
'params': {'skip_download': True},
|
||||
'skip': 'Georestricted in DE',
|
||||
}, {
|
||||
'url': 'https://www.bitchute.com/embed/lbb5G1hjPhw/',
|
||||
'only_matching': True,
|
||||
@ -128,25 +149,15 @@ class BitChuteIE(InfoExtractor):
|
||||
|
||||
def _call_api(self, endpoint, data, display_id, fatal=True):
|
||||
note = endpoint.rpartition('/')[2]
|
||||
try:
|
||||
return self._download_json(
|
||||
f'https://api.bitchute.com/api/beta/{endpoint}', display_id,
|
||||
f'Downloading {note} API JSON', f'Unable to download {note} API JSON',
|
||||
data=json.dumps(data).encode(),
|
||||
headers={
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
})
|
||||
except ExtractorError as e:
|
||||
if isinstance(e.cause, HTTPError) and e.cause.status == 403:
|
||||
errors = '. '.join(traverse_obj(e.cause.response.read().decode(), (
|
||||
{json.loads}, 'errors', lambda _, v: v['context'] == 'reason', 'message', {str})))
|
||||
if errors and 'location' in errors:
|
||||
# Can always be fatal since the video/media call will reach this code first
|
||||
self.raise_geo_restricted(errors)
|
||||
if fatal:
|
||||
raise
|
||||
self.report_warning(e.msg)
|
||||
# TODO: Add error handling for geo-restriction
|
||||
return self._download_json(
|
||||
f'https://api.bitchute.com/api/beta/{endpoint}', display_id,
|
||||
f'Downloading {note} API JSON', f'Unable to download {note} API JSON',
|
||||
fatal=fatal, data=json.dumps(data).encode(),
|
||||
headers={
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
})
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user