From dada78068b8616dbae3a8664ddbf6fd50d9b55a1 Mon Sep 17 00:00:00 2001 From: Tithen-Firion Date: Mon, 5 Oct 2020 11:24:20 +0200 Subject: [PATCH] [wetv] check error code in JSONP response --- youtube_dl/extractor/wetv.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/wetv.py b/youtube_dl/extractor/wetv.py index 987813a8f..0d78608ac 100644 --- a/youtube_dl/extractor/wetv.py +++ b/youtube_dl/extractor/wetv.py @@ -18,6 +18,7 @@ from ..compat import ( compat_urlparse, ) from ..utils import ( + ExtractorError, int_or_none, parse_duration, smuggle_url, @@ -121,7 +122,7 @@ class WeTvIE(WeTvBaseInfoExtractor): 'ext': 'mp4', 'title': 'Gokukoku no Brynhildr - "Ichiban Boshi" \u2014 Full Ending', }, - } + }, ] @staticmethod @@ -190,10 +191,20 @@ class WeTvIE(WeTvBaseInfoExtractor): jsonp_url = self.generate_jsonp_url(quality, video_id, *args) # "accept-encoding: gzip" results in # EOFError: Compressed file ended before the end-of-stream marker was reached - return self._download_json(jsonp_url, video_id, transform_source=strip_jsonp, + data = self._download_json(jsonp_url, video_id, transform_source=strip_jsonp, note='Downloading {} metadata'.format(quality), headers={'Accept-Encoding': 'deflate'}) + error_code = data.get('exem') + if error_code == 0: + return data + elif error_code == -2: + raise ExtractorError('This video is only available for VIP users.', expected=True) + elif error_code == -12: + raise ExtractorError('Bad encryption parameter') + else: + raise ExtractorError('Unknown error: [{}] {}'.format(error_code, data.get('msg'))) + @staticmethod def extract_qualities(data): qualities = []