[eagleplatform] Fix error handling
authorYen Chi Hsuan <yan12125@gmail.com>
Sat, 16 Apr 2016 08:47:16 +0000 (16:47 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Sat, 16 Apr 2016 08:47:16 +0000 (16:47 +0800)
youtube_dl/extractor/eagleplatform.py

index 7bbf617d468f9d5295ee2e1123452679a21a7e4b..fa3cb70231f57d3b6b11e31d2ebce70d5267690f 100644 (file)
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
 import re
 
 from .common import InfoExtractor
+from ..compat import compat_HTTPError
 from ..utils import (
     ExtractorError,
     int_or_none,
@@ -55,8 +56,13 @@ class EaglePlatformIE(InfoExtractor):
             raise ExtractorError(' '.join(response['errors']), expected=True)
 
     def _download_json(self, url_or_request, video_id, note='Downloading JSON metadata'):
-        response = super(EaglePlatformIE, self)._download_json(url_or_request, video_id, note)
-        self._handle_error(response)
+        try:
+            response = super(EaglePlatformIE, self)._download_json(url_or_request, video_id, note)
+        except ExtractorError as ee:
+            if isinstance(ee.cause, compat_HTTPError):
+                response = self._parse_json(ee.cause.read().decode('utf-8'), video_id)
+                self._handle_error(response)
+            raise
         return response
 
     def _get_video_url(self, url_or_request, video_id, note='Downloading JSON metadata'):