Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add queue reordering and shuffling #154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Blog Methods
client.followers(blogName) # get the followers of a blog
client.blog_following(blogName) # get the publicly exposed blogs that [blogName] follows
client.queue(blogName) # get the queue for a given blog
client.queue_reorder(blogName **params) # reorder posts in the queue of a blog relative to each other
client.queue_shuffle(blogName ) # randomly reorder the queue of a blog
client.submission(blogName) # get the submissions for a given blog

Post Methods
Expand Down
24 changes: 24 additions & 0 deletions pytumblr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,29 @@ def queue(self, blogname, **kwargs):
"""
url = "/v2/blog/{}/posts/queue".format(blogname)
return self.send_api_request("get", url, kwargs, ['limit', 'offset', 'filter', 'npf'])

@validate_blogname
def queue_reorder(self, blogname, **kwargs):
"""
Moves posts that are in the blog's queue

:param post_id: an int, the post you want to move
:param insert_after: an int, the id of the post you want the target post inserted after

:returns: a dict created from the JSON response
"""
url = "/v2/blog/{}/posts/queue/reorder".format(blogname)
return self.send_api_request("post", url, kwargs, ['post_id', 'insert_after'])

@validate_blogname
def queue_shuffle(self, blogname, **kwargs):
"""
Randomly shuffles posts that are in the blog's queue

:returns: a dict created from the JSON response
"""
url = "/v2/blog/{}/posts/queue/shuffle".format(blogname)
return self.send_api_request("post", url)

@validate_blogname
def drafts(self, blogname, **kwargs):
Expand Down Expand Up @@ -580,3 +603,4 @@ def send_api_request(self, method, url, params={}, valid_parameters=[], needs_ap
return self.request.delete(url, params)
else:
return self.request.post(url, params, files)