aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2015-05-02 00:32:46 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2015-05-02 01:20:15 +0800
commit89966a5aeacb70cc19b0a87a0514be824d2409af (patch)
treec5419dd39ae61e50c467eafef6b03d2b6db04725 /youtube_dl
parent8e3df9dfeef8503e9a8c01fcf42008d376d8d64d (diff)
[viki] Enhance error message handling (#3774)
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/viki.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/youtube_dl/extractor/viki.py b/youtube_dl/extractor/viki.py
index 957e3c01e..0fc1ceb19 100644
--- a/youtube_dl/extractor/viki.py
+++ b/youtube_dl/extractor/viki.py
@@ -11,6 +11,7 @@ from ..utils import (
unescapeHTML,
unified_strdate,
US_RATINGS,
+ clean_html,
)
from .common import InfoExtractor
@@ -71,10 +72,15 @@ class VikiIE(InfoExtractor):
req.add_header('User-Agent', self._USER_AGENT)
info_webpage = self._download_webpage(
req, video_id, note='Downloading info page')
- if re.match(r'\s*<div\s+class="video-error', info_webpage):
- raise ExtractorError(
- 'Video %s is blocked from your location.' % video_id,
- expected=True)
+ 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(
+ 'Video %s is blocked from your location.' % video_id,
+ expected=True)
+ else:
+ raise ExtractorError('Viki said: ' + err_msg)
video_url = self._html_search_regex(
r'<source[^>]+src="([^"]+)"', info_webpage, 'video URL')