[utils] Improve and test js_to_json
[youtube-dl] / youtube_dl / extractor / common.py
index f43a0a569a3d90d555a27cece8ac3e68951c5106..611cf95f1125ec9340a96554df9542d1fcbd62b4 100644 (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