[tumblr] add 'offset' option

This commit is contained in:
Mike Fährmann
2022-10-11 10:54:23 +02:00
parent 827ab0a62d
commit f1f89b2436
3 changed files with 18 additions and 1 deletions

View File

@@ -2328,6 +2328,18 @@ Description
Search posts for inline images and videos.
extractor.tumblr.offset
-----------------------
Type
``integer``
Default
``0``
Description
Custom ``offset`` starting value when paginating over blog posts.
Allows skipping over posts without having to waste API calls.
extractor.tumblr.original
-------------------------
Type

View File

@@ -297,6 +297,7 @@
"external": false,
"inline": true,
"posts": "all",
"offset": 0,
"original": true,
"reblogs": true
},

View File

@@ -435,11 +435,15 @@ class TumblrAPI(oauth.OAuth1API):
def posts(self, blog, params):
"""Retrieve published posts"""
params.update({"offset": 0, "limit": 50, "reblog_info": "true"})
params["offset"] = self.extractor.config("offset") or 0
params["limit"] = 50
params["reblog_info"] = "true"
if self.posts_type:
params["type"] = self.posts_type
if self.before:
params["before"] = self.before
while True:
data = self._call(blog, "posts", params)
self.BLOG_CACHE[blog] = data["blog"]