1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-22 08:34:32 +01:00

[bitchute] Fix error for geoblocking

Closes #26564.
This commit is contained in:
Adrian Heine 2020-09-11 23:31:44 +02:00
parent d51e23d9fc
commit 79d72c6f8c

View File

@ -6,6 +6,8 @@ import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError,
GeoRestrictedError,
orderedSet, orderedSet,
unified_strdate, unified_strdate,
urlencode_postdata, urlencode_postdata,
@ -59,8 +61,15 @@ class BitChuteIE(InfoExtractor):
for format_url in orderedSet(format_urls)] for format_url in orderedSet(format_urls)]
if not formats: if not formats:
formats = self._parse_html5_media_entries( entries = self._parse_html5_media_entries(
url, webpage, video_id)[0]['formats'] url, webpage, video_id)
if not entries:
error = self._html_search_regex(r'<h1 class="page-title">([^<]+)</h1>', webpage, 'error', default='Cannot find video')
error_detail = self._html_search_regex(r'(?s)</h1>.*<p>([^<]+)</p>', webpage, 'error_detail', default=None)
if error_detail == 'This video is unavailable as the contents have been deemed illegal by the authorities within your country.':
raise GeoRestrictedError(error_detail)
raise ExtractorError(error_detail or error)
formats = entries[0]['formats']
self._check_formats(formats, video_id) self._check_formats(formats, video_id)
self._sort_formats(formats) self._sort_formats(formats)