mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-08-28 18:15:19 +02:00
[viki] Enhance error message handling (#3774)
This commit is contained in:
parent
8e3df9dfee
commit
89966a5aea
@ -11,6 +11,7 @@
|
|||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
US_RATINGS,
|
US_RATINGS,
|
||||||
|
clean_html,
|
||||||
)
|
)
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
|
||||||
@ -71,10 +72,15 @@ def _real_extract(self, url):
|
|||||||
req.add_header('User-Agent', self._USER_AGENT)
|
req.add_header('User-Agent', self._USER_AGENT)
|
||||||
info_webpage = self._download_webpage(
|
info_webpage = self._download_webpage(
|
||||||
req, video_id, note='Downloading info page')
|
req, video_id, note='Downloading info page')
|
||||||
if re.match(r'\s*<div\s+class="video-error', info_webpage):
|
err_msg = self._html_search_regex(r'<div[^>]+class="video-error[^>]+>(.+)</div>', info_webpage, 'error message', default=None)
|
||||||
|
if err_msg:
|
||||||
|
err_msg = clean_html(err_msg)
|
||||||
|
if 'not available in your region' in err_msg:
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'Video %s is blocked from your location.' % video_id,
|
'Video %s is blocked from your location.' % video_id,
|
||||||
expected=True)
|
expected=True)
|
||||||
|
else:
|
||||||
|
raise ExtractorError('Viki said: ' + err_msg)
|
||||||
video_url = self._html_search_regex(
|
video_url = self._html_search_regex(
|
||||||
r'<source[^>]+src="([^"]+)"', info_webpage, 'video URL')
|
r'<source[^>]+src="([^"]+)"', info_webpage, 'video URL')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user