1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 03:02:50 +01:00

[gelbooru] display error for invalid API responses (#4903)

This commit is contained in:
Mike Fährmann 2024-01-06 14:26:46 +01:00
parent c25bdbae91
commit cbfb7bfdf1
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -32,10 +32,13 @@ class GelbooruBase():
url = self.root + "/index.php?page=dapi&q=index&json=1" url = self.root + "/index.php?page=dapi&q=index&json=1"
data = self.request(url, params=params).json() data = self.request(url, params=params).json()
if key not in data: try:
return () 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): if not isinstance(posts, list):
return (posts,) return (posts,)
return posts return posts