[tumblr:search] prevent KeyError when using 'offset' pagination (#8720)

This commit is contained in:
Mike Fährmann
2025-12-29 16:57:04 +01:00
parent ebfd87bbb0
commit ec2267244f

View File

@@ -531,12 +531,16 @@ class TumblrAPI(oauth.OAuth1API):
if self.api_key: if self.api_key:
params["api_key"] = self.api_key params["api_key"] = self.api_key
strategy = self.extractor.config("pagination") if strategy := self.extractor.config("pagination"):
if not strategy: if strategy not in {"api", "before"} and "offset" not in params:
if params.get("before"): self.log.warning('Unable to use "pagination": "%s". '
strategy = "before" 'Falling back to "api".', strategy)
elif "offset" not in params:
strategy = "api" strategy = "api"
elif params.get("before"):
strategy = "before"
elif "offset" not in params:
strategy = "api"
self.log.debug("Pagination strategy '%s'", strategy or "offset")
while True: while True:
data = self._call(endpoint, params) data = self._call(endpoint, params)