[tumblr] add 'offset' option
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -297,6 +297,7 @@
|
||||
"external": false,
|
||||
"inline": true,
|
||||
"posts": "all",
|
||||
"offset": 0,
|
||||
"original": true,
|
||||
"reblogs": true
|
||||
},
|
||||
|
||||
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user