Compare commits

..

No commits in common. "942aaf9c2904e0271c299f66ac0e90a30d360f38" and "260c331cc7d4e6d8c21d0d2263e8f64c293bbf09" have entirely different histories.

View File

@ -4,7 +4,6 @@ import re
from .common import InfoExtractor from .common import InfoExtractor
from ..networking import HEADRequest from ..networking import HEADRequest
from ..networking.exceptions import HTTPError
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
OnDemandPagedList, OnDemandPagedList,
@ -93,6 +92,28 @@ class BitChuteIE(InfoExtractor):
'timestamp': 1542130287, 'timestamp': 1542130287,
}, },
'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',
'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/', 'url': 'https://www.bitchute.com/embed/lbb5G1hjPhw/',
'only_matching': True, 'only_matching': True,
@ -128,25 +149,15 @@ class BitChuteIE(InfoExtractor):
def _call_api(self, endpoint, data, display_id, fatal=True): def _call_api(self, endpoint, data, display_id, fatal=True):
note = endpoint.rpartition('/')[2] note = endpoint.rpartition('/')[2]
try: # TODO: Add error handling for geo-restriction
return self._download_json( return self._download_json(
f'https://api.bitchute.com/api/beta/{endpoint}', display_id, f'https://api.bitchute.com/api/beta/{endpoint}', display_id,
f'Downloading {note} API JSON', f'Unable to download {note} API JSON', f'Downloading {note} API JSON', f'Unable to download {note} API JSON',
data=json.dumps(data).encode(), fatal=fatal, data=json.dumps(data).encode(),
headers={ headers={
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': '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)
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)