[utils] Improve and test js_to_json

This commit is contained in:
Philipp Hagemeister 2014-09-30 11:12:59 +02:00
parent 410f3e73ab
commit e7b6d12254
3 changed files with 38 additions and 25 deletions

View file

@ -334,7 +334,11 @@ class InfoExtractor(object):
try:
return json.loads(json_string)
except ValueError as ve:
raise ExtractorError('Failed to download JSON', cause=ve)
errmsg = '%s: Failed to parse JSON ' % video_id
if fatal:
raise ExtractorError(errmsg, cause=ve)
else:
self.report_warning(errmsg + str(ve))
def report_warning(self, msg, video_id=None):
idstr = '' if video_id is None else '%s: ' % video_id