Last active
November 25, 2018 20:28
-
-
Save andrewjkerr/478bd1664f0b3ca71f584d9404e439d7 to your computer and use it in GitHub Desktop.
A small lil' script to properly format, tag, and queue submissions for a popular Tumblr blog that I run.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tumblr_client' | |
client = Tumblr::Client.new({ | |
consumer_key: 'TUMBLR_CONSUMER_KEY', | |
consumer_secret: 'TUMBLR_CONSUMER_SECRET', | |
oauth_token: 'TUMBLR_OAUTH_TOKEN', | |
oauth_token_secret: 'TUMBLR_OAUTH_TOKEN_SECRET' | |
}) | |
submissions = client.submissions('dogs.tumblr.com') | |
submissions['posts'].each do |post| | |
post_author = post['post_author'] | |
current_body = post['body'] | |
body = "#{current_body}<p>(Submitted by @#{post_author} | <a href='https://dogs.tumblr.com/submit'>Submit your woofer!</a> | <a href='https://dogs.tumblr.com/tagged/submission'>See more doggos</a>)</p>" | |
tags = [ | |
post_author, | |
'submission', | |
'dog', | |
'dogs', | |
'cute', | |
'animal', | |
'animals', | |
'adorable', | |
'cute', | |
'puppylove', | |
'puppy', | |
'puppies', | |
'love dogs', | |
'doglover', | |
'cute dogs' | |
] | |
client.edit( | |
'dogs.tumblr.com', | |
id: post['id'].to_i, | |
state: 'queue', | |
body: body, | |
tags: tags | |
) | |
end | |
puts "Done! Check out https://www.tumblr.com/blog/dogs/queue for the new queued posts." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment