Skip to content

Instantly share code, notes, and snippets.

@perplexes
Last active December 14, 2015 02:49
Show Gist options
  • Save perplexes/5016626 to your computer and use it in GitHub Desktop.
Save perplexes/5016626 to your computer and use it in GitHub Desktop.
A small script for moving from tumblr to wordpress
require 'xmlrpc/client'
wordpress = XMLRPC::Client.new('academiaedu.wordpress.com', '/xmlrpc.php')
require 'tumblr_client'
# To get these:
# Go to http://tumblr-rb.herokuapp.com/ (a service for the below)
# --OR--
# `gem install tumblr-rb` somewhere with a public ip address
# `tumblr authorize` will spin up a web server
# go to that page, it'll step you through everything
# copy the values in ~/.tumblr to here
Tumblr.configure do |config|
config.consumer_key = "consumer_key"
config.consumer_secret = "consumer_secret"
config.oauth_token = "oauth_token"
config.oauth_token_secret = "oauth_token_secret"
end
tumblr = Tumblr::Client.new
tumblr.posts('yourtumblr.tumblr.com')['posts'].each do |t_post|
post = {
'title' => t_post['title'] || "", # Non-blog post
'description' => t_post['body'] || t_post['caption'], # Non-blog post
'mt_keywords' => t_post['tags'],
# 'categories' => ['a', 'list', 'of', 'categories']
'dateCreated' => Time.at(t_post['timestamp']).to_date
}
wordpress.call(
'metaWeblog.newPost',
1,
'wordpress_user',
'wordpress_pass',
post,
true
)
puts t_post['title']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment