Created
October 26, 2009 05:46
-
-
Save knzai/218453 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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