From 9e07cf2955ce3fc7dc7c4676ec32da9bfd6e3990 Mon Sep 17 00:00:00 2001 From: Juan M Date: Tue, 26 Feb 2013 18:06:43 +0100 Subject: [PATCH] [YT Search] No results if items is not in response When a query results of 0 items, the key items is not present in the api_response dictionary, raising a KeyError. Intead, look for the key and call trouble if it's not present. --- youtube_dl/InfoExtractors.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index d661d517de..a9646433ef 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -1478,6 +1478,10 @@ class YoutubeSearchIE(InfoExtractor): return api_response = json.loads(data)['data'] + if not 'items' in api_response: + self._downloader.trouble(u'[youtube] No video results') + return + new_ids = list(video['id'] for video in api_response['items']) video_ids += new_ids