From cbfb7bfdf175d29beb655c2e96107956c2df346b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 6 Jan 2024 14:26:46 +0100 Subject: [PATCH] [gelbooru] display error for invalid API responses (#4903) --- gallery_dl/extractor/gelbooru.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/gelbooru.py b/gallery_dl/extractor/gelbooru.py index d9da7bc3f1..eba1539012 100644 --- a/gallery_dl/extractor/gelbooru.py +++ b/gallery_dl/extractor/gelbooru.py @@ -32,10 +32,13 @@ def _api_request(self, params, key="post"): url = self.root + "/index.php?page=dapi&q=index&json=1" data = self.request(url, params=params).json() - if key not in data: - return () + try: + posts = data[key] + except KeyError: + self.log.error("Incomplete API response (missing '%s')", key) + self.log.debug("%s", data) + return [] - posts = data[key] if not isinstance(posts, list): return (posts,) return posts