[tumblr] fix pagination when using 'date-max'
This commit is contained in:
@@ -5277,7 +5277,8 @@ extractor.tumblr.pagination
|
|||||||
Type
|
Type
|
||||||
``string``
|
``string``
|
||||||
Default
|
Default
|
||||||
``"offset"``
|
* ``"before"`` if `date-max <extractor.tumblr.date-min & .date-max_>`__ is set
|
||||||
|
* ``"offset"`` otherwise
|
||||||
Description
|
Description
|
||||||
Controls how to paginate over blog posts.
|
Controls how to paginate over blog posts.
|
||||||
|
|
||||||
|
|||||||
@@ -779,7 +779,7 @@
|
|||||||
"inline" : true,
|
"inline" : true,
|
||||||
"offset" : 0,
|
"offset" : 0,
|
||||||
"original" : true,
|
"original" : true,
|
||||||
"pagination": "offset",
|
"pagination": null,
|
||||||
"posts" : "all",
|
"posts" : "all",
|
||||||
"ratelimit" : "abort",
|
"ratelimit" : "abort",
|
||||||
"reblogs" : true,
|
"reblogs" : true,
|
||||||
|
|||||||
@@ -550,8 +550,11 @@ class TumblrAPI(oauth.OAuth1API):
|
|||||||
params["api_key"] = self.api_key
|
params["api_key"] = self.api_key
|
||||||
|
|
||||||
strategy = self.extractor.config("pagination")
|
strategy = self.extractor.config("pagination")
|
||||||
if not strategy and "offset" not in params:
|
if not strategy:
|
||||||
strategy = "api"
|
if params.get("before"):
|
||||||
|
strategy = "before"
|
||||||
|
elif "offset" not in params:
|
||||||
|
strategy = "api"
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
data = self._call(endpoint, params)
|
data = self._call(endpoint, params)
|
||||||
@@ -573,10 +576,9 @@ class TumblrAPI(oauth.OAuth1API):
|
|||||||
endpoint = data["_links"]["next"]["href"]
|
endpoint = data["_links"]["next"]["href"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
if params is not None and self.api_key:
|
||||||
params = None
|
endpoint = f"{endpoint}&api_key={self.api_key}"
|
||||||
if self.api_key:
|
params = None
|
||||||
endpoint += "&api_key=" + self.api_key
|
|
||||||
|
|
||||||
elif strategy == "before":
|
elif strategy == "before":
|
||||||
if not posts:
|
if not posts:
|
||||||
|
|||||||
Reference in New Issue
Block a user