Skip to content

Instantly share code, notes, and snippets.

@knzconnor
Created October 26, 2009 05:46
Show Gist options
  • Save knzconnor/218453 to your computer and use it in GitHub Desktop.
Save knzconnor/218453 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#With thanks to http://tonybuser.com/post/188055319/importing-typo-to-tumblr for the initial seed
require "rubygems"
require "hpricot"
require "httparty"
class Tumblr
include HTTParty
base_uri 'www.tumblr.com'
default_params :generator => "Tim Connor's Tumblr Importer http://gist.github.com/218453",
:type => "regular", :format => "html"
def self.configure(account, email, password)
@account = account
@email = email
@password = password
nil
end
def self.import(params)
raise StandardError, "call configure first" unless @password
params.update(:group => "#{@account}.tumblr.com", :email => @email, :password => @password)
if tags = params[:tags] && tags.is_a?(Array)
params[:tags] = tags.join(',')
end
post("/api/write", :body => params)
end
end
# puts Tumblr.import(:date => Date.today, :url => 'http://oldblog.timocracy.com/2009/10/25/moving-on', :name => 'moving on', :tags => 'tessting', :type => 'link', :description => "An imported post from my old blog. Hopefully the title is self-explantory.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment