I wanted to import all my Connotea bookmarks into my Del.icio.us account for a small experiment I was running. So I glued together the two APIs with a simple Ruby script.
The script uses the Ridiculous wrapper for the Del.icio.us API and my own www-connotea-ruby for the Connotea Web API.
I had problems installing Ridiculous from Rubygems, so I pulled it down from the SVN repository
$ svn co svn://rubyforge.org//var/svn/ridiculous/0.5
I had to patch ridiculous.rb with this.
I downloaded www-connotea-ruby and extracted it
$ tar xvzf www-connotea-ruby-0.1.tar.gz
And the connecting glue was just a few lines:
#!/usr/bin/env ruby # contodel.rb # by Ben Lund, Jan 2007 # Usage: ruby contodel.rb connotea_username:connotea_password delicious_username:delicious_password require '0.5/ridiculous' require 'www-connotea-ruby-0.1/lib/www/connotea' c_user, c_pass = *ARGV.shift.split(/:/) Ridiculous::USERNAME, Ridiculous::PASSWORD = *ARGV.shift.split(/:/) c = WWW::Connotea.new(:user => c_user, :password => c_pass) c.posts_for(:user=> c_user) do |p| success = false begin success = Ridiculous::Post.new.add( :url => p.link, :description => p.title || p.link, :extended => p.description, # Convert multi-word tags to underscore-separated # And convert all to lowercase to overcome case-insensitivity :tags => p.tags.map{|t| t.gsub(/\s+/, '_').downcase }.join(' ') ) end raise "Couldn't post #{p.link}" unless success #give the del.icio.us server a rest sleep(1) end
Update: Via Stew, a script to go back the other way from Konstantin Baierer.