« Improving my Emacs Configurations | Main | Ruby Fitbit API »

Converting Movable Type to Tumblr

Continuing my work on converting this blog to be a dev blog, I moved over all non development and computer related posts to my personal blog. I just converted about 1,000 posts and 3,000 comments from MovableType to Tumblr and Disqus.

I decided I would host my personal blog on Tumblr, which has been interesting so far. Sucking the old posts and comments out of MovableType and pushing them to Tumblr wasn't as easy as I had hoped. Although it gave me a chance to enjoy on of my favorite parts of being a developer. If something doesn't exist and I want it, I can built it. So I set off to write a script that would take a Movable Type blog export and import all of the posts into Tumblr and push all of the comments to Disqus. While it wasn't the easiest thing to do, it wasn't that difficult either. I have slowly built up a collection of various utilities to help port from Movable Type to Wordpress, or from wordpress.org to wordpress.com. Things that help clean up formatting or remove javascript and replace it with something allowed on wordpress.org. I added my conversion script to the inconveniently named MT_WP_Converter git repo.

View MovableType to Tumblr Converter Script

Quick Gotchas:
* There are lots of older or bad example code on how to use the disqus API out there, I had a problem posting comments because all of the POST endpoints must end with a '/', which I didn't know. This forum post helped me fix an issue posting to disqus with rest client.
* Remember to turn off the facebook publishing for tumblr, before doing the import or testing it. I didn't remember this and published the same test post on facebook about 40 times. Oops!

Comments (8)

This is a test to check the captcha, does it work?

this captcha works.

Ian:

I am trying to use your ruby script, but it's all new to me.
I've installed ruby 1.8.7 on windows and that errored with "mt_tumblr_converter.rb:3:in `require': no such file to load -- ruby-debug (LoadError)"

I thought I managed to install the ruby-debug gem package but it never seemed to work. Is there a list if the required gems or are they just the "require" entries?

I realise the error is probably not related to your script but can you let me know which version of ruby and what platform you ran this on?

Thanks.

Ian:

OK, so I think I've got past that problem but another one has appeared.
Any help would be be greatly appreciated.

:29:in `require': no such file to load --
main (LoadError)
from :29:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/tumblr-2.2.0/lib/tumblr.rb:14:i
n `'
from :33:in `require'
from :33:in `rescue in require'
from :29:in `require'
from c:/Shared/Tumblr Upload/mt_tumblr_converter.rb:10:in `'

Ian:

I have progressed once more, this time I had the wrong Tumblr gem, I removed the tumblr gem and added the tumblr-rb and now that error has gone, but another one has come.

net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded
an error occured parsing this entry, error: wrong status line: "

Where should I be setting the Content-Type? I presume it is just plain text.

Thanks again.

Sorry I really posted this as code for developer's to play around with or edit, I am not supporting it or trying to make it work for fully general purpose use. Good luck getting it all working, if you know ruby and a bit of coding, it should work for you. If not it is probably a bit over the head of a typical computer user.

Thanks,
Dan

Ian:

Thanks for the feedback Dan.
The HTML message above was only a warning and there seem to be plenty of those with Ruby.

I've got it working for basic posts but I really would like to import some posts with photos associated.

I looked at your script and also the tumblr-rb gem to understand how it works. I've changed line 101 to change the post type from regular to photo as below.
:type => :regular to :type => :photo

But this then gives an error when running the script. I've put the photo URL in the BODY as specified by the Gem.


Exception `TypeError' at mt_tumblr_converter.rb:103 - can't convert String into Integer
an error occured parsing this entry, error: can't convert String into Integer
#

Any pointers would be welcomed as to why this doesn't work?
Thanks Again.

Sorry I took a quick look and don't know what that is off the top of my head. You could try to run the converter with

require 'ruby-debug'; debugger above that line and view the data that is blowing up. It might be as simple as calling .to_s on something or interpolating it as a string "#{var_that_needs_to_be_string}"

you could also surround that part of the script in

begin
#bad lines that cause the error
rescue => error
puts "error: #{error}: #{error.backtrace.join("\n")}"
end

which will print out more info about the error.

Post a comment


Type the characters you see in the picture above.

Web 2.0 craziness

View Dan Mayer's profile on LinkedIn


I Power Seekler
I Power Seekler

www.flickr.com
This is a Flickr badge showing public photos and videos from mayer_dan. Make your own badge here.

Creative Commons License
This weblog is licensed under a Creative Commons License.