[amp] extract error message(closes #12795)
authorRemita Amine <remitamine@gmail.com>
Thu, 20 Apr 2017 04:16:41 +0000 (05:16 +0100)
committerRemita Amine <remitamine@gmail.com>
Thu, 20 Apr 2017 04:16:41 +0000 (05:16 +0100)
youtube_dl/extractor/amp.py

index e8e40126baca4bad27f8593dd9bd026f16fad131..98f8e69cdc7780da950c2b0d0f46a498d2883d33 100644 (file)
@@ -7,15 +7,19 @@ from ..utils import (
     parse_iso8601,
     mimetype2ext,
     determine_ext,
+    ExtractorError,
 )
 
 
 class AMPIE(InfoExtractor):
     # parse Akamai Adaptive Media Player feed
     def _extract_feed_info(self, url):
-        item = self._download_json(
+        feed = self._download_json(
             url, None, 'Downloading Akamai AMP feed',
-            'Unable to download Akamai AMP feed')['channel']['item']
+            'Unable to download Akamai AMP feed')
+        item = feed.get('channel', {}).get('item')
+        if not item:
+            raise ExtractorError('%s said: %s' % (self.IE_NAME, feed['error']))
 
         video_id = item['guid']