Skip to content

Instantly share code, notes, and snippets.

@andrewjkerr
Created November 30, 2016 06:20
Show Gist options
  • Save andrewjkerr/070cb02cab89b7c6dc5ca0073339a7b2 to your computer and use it in GitHub Desktop.
Save andrewjkerr/070cb02cab89b7c6dc5ca0073339a7b2 to your computer and use it in GitHub Desktop.
A super quick and dirty script to draft a bunch of posts based on a certain tag.
require 'tumblr_client'
# Get dat Tumblr client
client = Tumblr::Client.new({
consumer_key: 'CONSUMER_KEY',
consumer_secret: 'CONSUMER_SECRET',
oauth_token: 'OAUTH_TOKEN',
oauth_token_secret: 'OAUTH_TOKEN_SECRET'
})
# Config your stuff here
tag = 'TAG_TO_REBLOG'
blog_url = 'YOUR_BLOG.tumblr.com' # or whatever CNAME you have set
tags_to_post = [
'TAG_1',
'TAG_2',
'TAG_3'
]
# Form the comma separated string required to tag posts via the API
tags_to_post_str = tags_to_post.join(',')
# Get the initial tagged stuff
tagged = client.tagged(tag)
post = tagged.first
# Drafts 100 posts w/ the tag
5.times do
tagged.each do |post|
id = post['id']
reblog_key = post['reblog_key']
client.reblog(blog_url,
id: id,
reblog_key: reblog_key,
state: 'draft',
tags: tags_to_post_str
)
end
last_timestamp = tagged.last['timestamp']
tagged = client.tagged(tag,
before: last_timestamp
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment