Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Created November 25, 2011 12:40
Show Gist options
  • Save timurvafin/1393432 to your computer and use it in GitHub Desktop.
Save timurvafin/1393432 to your computer and use it in GitHub Desktop.
require "rubygems"
require "bundler/setup"
require "httparty"
require "active_support/all"
class TumblrApi
include HTTParty
base_uri 'http://www.tumblr.com'
default_params :email => '',
:password => '',
:state => 'draft',
:type => 'regular',
:format => 'html'
end
posts = Hash.from_xml(File.read('wordpress.2011-11-18.xml'))
posts['rss']['channel']['item'].each do |post|
next if post['status'] != 'publish' || post['post_type'] != 'post'
tags = ((post['category'] || []).uniq - ['General', 'Resources', 'RubyOnRails', 'Scrum']).join(', ')
body = post['encoded'].join
TumblrApi.post('/api/write', :body => {
:title => post['title'],
:body => body,
:date => post['post_date'],
:tags => tags,
:slug => post['post_name'],
:group => 'flatstack-group.tumblr.com'
})
puts "#{post['title']}"
end
source :rubyforge
gem "httparty"
gem "activesupport"
gem "i18n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment