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:
parent
c25bdbae91
commit
cbfb7bfdf1
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user