Skip to content

Commit

Permalink
[gelbooru] only log "Incomplete API response" for favorites (#5045)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jan 10, 2024
1 parent 39904c9 commit bbf9675
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions gallery_dl/extractor/gelbooru.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GelbooruBase():
root = "https://gelbooru.com"
offset = 0

def _api_request(self, params, key="post"):
def _api_request(self, params, key="post", log=False):
if "s" not in params:
params["s"] = "post"
params["api_key"] = self.api_key
Expand All @@ -35,8 +35,9 @@ def _api_request(self, params, key="post"):
try:
posts = data[key]
except KeyError:
self.log.error("Incomplete API response (missing '%s')", key)
self.log.debug("%s", data)
if log:
self.log.error("Incomplete API response (missing '%s')", key)
self.log.debug("%s", data)
return []

if not isinstance(posts, list):
Expand Down Expand Up @@ -169,7 +170,7 @@ def posts(self):
"limit": "1",
}

count = self._api_request(params, "@attributes")[0]["count"]
count = self._api_request(params, "@attributes", True)[0]["count"]
if count <= self.offset:
return

Expand All @@ -186,7 +187,7 @@ def posts(self):
params["limit"] = self.per_page

while True:
favs = self._api_request(params, "favorite")
favs = self._api_request(params, "favorite", True)
favs.reverse()

if skip:
Expand Down

0 comments on commit bbf9675

Please sign in to comment.