[gelbooru] only log "Incomplete API response" for favorites (#5045)
This commit is contained in:
@@ -23,7 +23,7 @@ class GelbooruBase():
|
|||||||
root = "https://gelbooru.com"
|
root = "https://gelbooru.com"
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
||||||
def _api_request(self, params, key="post"):
|
def _api_request(self, params, key="post", log=False):
|
||||||
if "s" not in params:
|
if "s" not in params:
|
||||||
params["s"] = "post"
|
params["s"] = "post"
|
||||||
params["api_key"] = self.api_key
|
params["api_key"] = self.api_key
|
||||||
@@ -35,8 +35,9 @@ class GelbooruBase():
|
|||||||
try:
|
try:
|
||||||
posts = data[key]
|
posts = data[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.log.error("Incomplete API response (missing '%s')", key)
|
if log:
|
||||||
self.log.debug("%s", data)
|
self.log.error("Incomplete API response (missing '%s')", key)
|
||||||
|
self.log.debug("%s", data)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if not isinstance(posts, list):
|
if not isinstance(posts, list):
|
||||||
@@ -169,7 +170,7 @@ class GelbooruFavoriteExtractor(GelbooruBase,
|
|||||||
"limit": "1",
|
"limit": "1",
|
||||||
}
|
}
|
||||||
|
|
||||||
count = self._api_request(params, "@attributes")[0]["count"]
|
count = self._api_request(params, "@attributes", True)[0]["count"]
|
||||||
if count <= self.offset:
|
if count <= self.offset:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -186,7 +187,7 @@ class GelbooruFavoriteExtractor(GelbooruBase,
|
|||||||
params["limit"] = self.per_page
|
params["limit"] = self.per_page
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
favs = self._api_request(params, "favorite")
|
favs = self._api_request(params, "favorite", True)
|
||||||
favs.reverse()
|
favs.reverse()
|
||||||
|
|
||||||
if skip:
|
if skip:
|
||||||
|
|||||||
Reference in New Issue
Block a user