[tumblr] fix pagination when using 'date-max'

This commit is contained in:
Mike Fährmann
2025-09-02 10:14:11 +02:00
parent 52c932add6
commit ff147c2a32
3 changed files with 11 additions and 8 deletions

View File

@@ -5277,7 +5277,8 @@ extractor.tumblr.pagination
Type
``string``
Default
``"offset"``
* ``"before"`` if `date-max <extractor.tumblr.date-min & .date-max_>`__ is set
* ``"offset"`` otherwise
Description
Controls how to paginate over blog posts.

View File

@@ -779,7 +779,7 @@
"inline" : true,
"offset" : 0,
"original" : true,
"pagination": "offset",
"pagination": null,
"posts" : "all",
"ratelimit" : "abort",
"reblogs" : true,

View File

@@ -550,8 +550,11 @@ class TumblrAPI(oauth.OAuth1API):
params["api_key"] = self.api_key
strategy = self.extractor.config("pagination")
if not strategy and "offset" not in params:
strategy = "api"
if not strategy:
if params.get("before"):
strategy = "before"
elif "offset" not in params:
strategy = "api"
while True:
data = self._call(endpoint, params)
@@ -573,10 +576,9 @@ class TumblrAPI(oauth.OAuth1API):
endpoint = data["_links"]["next"]["href"]
except KeyError:
return
params = None
if self.api_key:
endpoint += "&api_key=" + self.api_key
if params is not None and self.api_key:
endpoint = f"{endpoint}&api_key={self.api_key}"
params = None
elif strategy == "before":
if not posts: