ソースを参照

[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.
Juan M 12 年 前
コミット
9e07cf2955
1 ファイル変更4 行追加0 行削除
  1. 4 0
      youtube_dl/InfoExtractors.py

+ 4 - 0
youtube_dl/InfoExtractors.py

@@ -1478,6 +1478,10 @@ class YoutubeSearchIE(InfoExtractor):
                 return
                 return
             api_response = json.loads(data)['data']
             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'])
             new_ids = list(video['id'] for video in api_response['items'])
             video_ids += new_ids
             video_ids += new_ids