[bambuser] Capture and output error message (#5478)

pull/8/head
Sergey M․ 10 years ago
parent bda44f31a1
commit ae8953409e

@ -1,13 +1,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re import re
import json
import itertools import itertools
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import ( from ..compat import compat_urllib_request
compat_urllib_request, from ..utils import ExtractorError
)
class BambuserIE(InfoExtractor): class BambuserIE(InfoExtractor):
@ -39,17 +37,24 @@ class BambuserIE(InfoExtractor):
info = self._download_json( info = self._download_json(
'http://player-c.api.bambuser.com/getVideo.json?api_key=%s&vid=%s' '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 { return {
'id': video_id, 'id': video_id,
'title': info['title'], 'title': result['title'],
'url': info['url'], 'url': result['url'],
'thumbnail': info.get('preview'), 'thumbnail': result.get('preview'),
'duration': int(info['length']), 'duration': int(result['length']),
'view_count': int(info['views_total']), 'view_count': int(result['views_total']),
'uploader': info['username'], 'uploader': result['username'],
'uploader_id': info['owner']['uid'], 'uploader_id': result['owner']['uid'],
} }

Loading…
Cancel
Save