Skip to content

Instantly share code, notes, and snippets.

@simonszu
Created June 16, 2015 17:47
Show Gist options
  • Select an option

  • Save simonszu/5306c0719eeaeec5fe93 to your computer and use it in GitHub Desktop.

Select an option

Save simonszu/5306c0719eeaeec5fe93 to your computer and use it in GitHub Desktop.
Slowly post the content of a directory of images to tumblr
#! /usr/bin/env ruby
require 'tumblr_client'
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
Tumblr.configure do |config|
config.consumer_key = consumer_key
config.consumer_secret = consumer_secret
config.oauth_token = access_token
config.oauth_token_secret = access_token_secret
end
client = Tumblr::Client.new
#Dir.entries("/home/simonszu/soup-simonszu").first do |filename|
# puts filename
#end
filename = Dir.entries("/path/to/pictures").last
if ((!filename.eql? ".") && (!filename.eql? ".."))
fullpath = File.join("/path/to/pictures", filename)
puts filename
puts fullpath
client.photo("yourname.tumblr.com", {:data => [fullpath], :caption => "Autoimport - #{filename}" })
File.delete(fullpath)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment