From ec2267244f447d459cd589969dd9e1434886d1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 29 Dec 2025 16:57:04 +0100 Subject: [PATCH] [tumblr:search] prevent KeyError when using 'offset' pagination (#8720) --- gallery_dl/extractor/tumblr.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/tumblr.py b/gallery_dl/extractor/tumblr.py index bd274168..bd597807 100644 --- a/gallery_dl/extractor/tumblr.py +++ b/gallery_dl/extractor/tumblr.py @@ -531,12 +531,16 @@ class TumblrAPI(oauth.OAuth1API): if self.api_key: params["api_key"] = self.api_key - strategy = self.extractor.config("pagination") - if not strategy: - if params.get("before"): - strategy = "before" - elif "offset" not in params: + if strategy := self.extractor.config("pagination"): + if strategy not in {"api", "before"} and "offset" not in params: + self.log.warning('Unable to use "pagination": "%s". ' + 'Falling back to "api".', strategy) 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: data = self._call(endpoint, params)