Skip to content

Instantly share code, notes, and snippets.

@toto
Created June 26, 2010 18:39
Show Gist options
  • Save toto/454253 to your computer and use it in GitHub Desktop.
Save toto/454253 to your computer and use it in GitHub Desktop.
require 'yaml'
require 'xmlrpc/client'
typo = XMLRPC::Client.new('blog.host.name', '/backend/xmlrpc')
posts = typo.call('metaWeblog.getRecentPosts', '1', 'username', 'password', 1_000_000).select{|p| !p['description'].nil?}.collect do |post|
{'title' => post['title'],
'body' => post['description'],
'body_converter' => post['mt_convert_breaks'],
'tags' => post['mt_keywords'],
'categories' => post['categories'],
'url' => post['permaLink'],
'slug' => post['permaLink'].split('/').last,
'created_at' => post['dateCreated'].to_time}
end
File.open(File.expand_path('~/export.yaml'), 'w+') do |f|
f.write posts.to_yaml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment