Closed DrunkCodes closed 6 years ago
It's not documented, but there is a parameter that you can specify with the date and time for a post to be published when setting up a "queued" post: publish_on
import pytumblr
# pytumblr does not currently have support for setting 'publish_on', but this adds it for this file
old_post_valid_options = pytumblr.TumblrRestClient._post_valid_options
def new_post_valid_options(self, post_type=None):
return ['publish_on'] + old_post_valid_options(self, post_type)
pytumblr.TumblrRestClient._post_valid_options = new_post_valid_options
client = pytumblr.TumblrRestClient(...) # pass in your credentials
txt = client.create_text(
"blogName",
state="queue",
publish_on="2018-05-17T21:59:00", # I believe this time needs to be in UTC
title="Testing",
body="body of text post")
Thanks.
But am still trying to understand the code.
No big deal. I can still use it.
The pytumblr.TumblrRestClient._post_valid_options = new_post_valid_options
line is basically monkey-patching the pytumblr code to change its behavior.
Because the pytumblr
code that you're using was probably installed with pip
, you can't easily edit it and it does not currently allow you to use the param publish_on
, so this code changes how pytumblr works when used in this file to add publish_on
as a valid parameter to use.
Please I have being looking for away to add the schedule state to my post.
Any help will be appreciated .