mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-01-31 07:09:49 +00:00
Raise descriptive ExtractorError
This commit is contained in:
parent
fa8f6d8580
commit
4ecbc49a15
@ -110,11 +110,24 @@ class FunimationIE(InfoExtractor):
|
|||||||
headers = {}
|
headers = {}
|
||||||
if self._TOKEN:
|
if self._TOKEN:
|
||||||
headers['Authorization'] = 'Token %s' % self._TOKEN
|
headers['Authorization'] = 'Token %s' % self._TOKEN
|
||||||
sources = self._download_json(
|
try:
|
||||||
'https://www.funimation.com/api/showexperience/%s/' % video_id,
|
sources = self._download_json(
|
||||||
video_id, headers=headers, query={
|
'https://www.funimation.com/api/showexperience/%s/' % video_id,
|
||||||
'pinst_id': ''.join([random.choice(string.digits + string.ascii_letters) for _ in range(8)]),
|
video_id, headers=headers, query={
|
||||||
})['items']
|
'pinst_id': ''.join([random.choice(string.digits + string.ascii_letters) for _ in range(8)]),
|
||||||
|
})
|
||||||
|
sources = sources['items']
|
||||||
|
except KeyError:
|
||||||
|
if 'errors' in sources:
|
||||||
|
errors = sources['errors']
|
||||||
|
if len(errors) > 0:
|
||||||
|
error = errors[0]
|
||||||
|
if 'detail' in error:
|
||||||
|
detail = error['detail']
|
||||||
|
raise ExtractorError('%s said: %s' % (
|
||||||
|
self.IE_NAME, detail), expected=True)
|
||||||
|
else:
|
||||||
|
raise ExtractorError(error, expected=True)
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
|
||||||
error = self._parse_json(e.cause.read(), video_id)['errors'][0]
|
error = self._parse_json(e.cause.read(), video_id)['errors'][0]
|
||||||
|
Loading…
Reference in New Issue
Block a user