aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2017-09-02 15:44:49 +0700
committerSergey M․ <dstftw@gmail.com>2017-09-02 15:44:49 +0700
commit64f0e30b93db804323a6db382d4ccdf1dac4e38b (patch)
tree1edabd64d6d08d61573972ed31567b095c111392
parenta3431e12249530aa7a6962e54bcdbfce190c4c4d (diff)
downloadyoutube-dl-64f0e30b93db804323a6db382d4ccdf1dac4e38b.tar.xz
[viidea] Capture and output lecture error message (#14099)
-rw-r--r--youtube_dl/extractor/viidea.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/youtube_dl/extractor/viidea.py b/youtube_dl/extractor/viidea.py
index 4adcd1830..a0abbae60 100644
--- a/youtube_dl/extractor/viidea.py
+++ b/youtube_dl/extractor/viidea.py
@@ -4,12 +4,14 @@ import re
from .common import InfoExtractor
from ..compat import (
- compat_urlparse,
+ compat_HTTPError,
compat_str,
+ compat_urlparse,
)
from ..utils import (
- parse_duration,
+ ExtractorError,
js_to_json,
+ parse_duration,
parse_iso8601,
)
@@ -128,9 +130,16 @@ class ViideaIE(InfoExtractor):
base_url = self._proto_relative_url(cfg['livepipe'], 'http:')
- lecture_data = self._download_json(
- '%s/site/api/lecture/%s?format=json' % (base_url, lecture_id),
- lecture_id)['lecture'][0]
+ try:
+ lecture_data = self._download_json(
+ '%s/site/api/lecture/%s?format=json' % (base_url, lecture_id),
+ lecture_id)['lecture'][0]
+ except ExtractorError as e:
+ if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
+ msg = self._parse_json(
+ e.cause.read().decode('utf-8'), lecture_id)
+ raise ExtractorError(msg['detail'], expected=True)
+ raise
lecture_info = {
'id': lecture_id,