[tumblr] fix pagination when using 'date-max'
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -779,7 +779,7 @@
|
||||
"inline" : true,
|
||||
"offset" : 0,
|
||||
"original" : true,
|
||||
"pagination": "offset",
|
||||
"pagination": null,
|
||||
"posts" : "all",
|
||||
"ratelimit" : "abort",
|
||||
"reblogs" : true,
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user