diff options
author | Sergey M․ <dstftw@gmail.com> | 2015-04-20 22:35:53 +0600 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2015-04-20 22:35:53 +0600 |
commit | ae8953409e30ef9d7dd6bc40350fccc2a29ffb4b (patch) | |
tree | 9c4510749d87faa1f896fce235bf2a504b1b0372 /youtube_dl/extractor/bambuser.py | |
parent | bda44f31a1e18d71dc1cc7a2a3a754593ecd63d3 (diff) |
[bambuser] Capture and output error message (#5478)
Diffstat (limited to 'youtube_dl/extractor/bambuser.py')
-rw-r--r-- | youtube_dl/extractor/bambuser.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/youtube_dl/extractor/bambuser.py b/youtube_dl/extractor/bambuser.py index 12673e766..d52302ebc 100644 --- a/youtube_dl/extractor/bambuser.py +++ b/youtube_dl/extractor/bambuser.py @@ -1,13 +1,11 @@ from __future__ import unicode_literals import re -import json import itertools from .common import InfoExtractor -from ..compat import ( - compat_urllib_request, -) +from ..compat import compat_urllib_request +from ..utils import ExtractorError class BambuserIE(InfoExtractor): @@ -39,17 +37,24 @@ class BambuserIE(InfoExtractor): info = self._download_json( 'http://player-c.api.bambuser.com/getVideo.json?api_key=%s&vid=%s' - % (self._API_KEY, video_id), video_id)['result'] + % (self._API_KEY, video_id), video_id) + + error = info.get('error') + if error: + raise ExtractorError( + '%s returned error: %s' % (self.IE_NAME, error), expected=True) + + result = info['result'] return { 'id': video_id, - 'title': info['title'], - 'url': info['url'], - 'thumbnail': info.get('preview'), - 'duration': int(info['length']), - 'view_count': int(info['views_total']), - 'uploader': info['username'], - 'uploader_id': info['owner']['uid'], + 'title': result['title'], + 'url': result['url'], + 'thumbnail': result.get('preview'), + 'duration': int(result['length']), + 'view_count': int(result['views_total']), + 'uploader': result['username'], + 'uploader_id': result['owner']['uid'], } |