Del.icio.us to Yojimbo
Sunday May 20th 2007, 2:30 am
By Theron Parlin
Tags: RubyOSA, Yojimbo, bookmarks, del.icio.us, import, ruby

So I’ve been playing around with different information organizers. I recently wrote about Journler, which is a really good free option. However, after trying out the demo for Yojimbo, I decided to switch. One of the reasons I like Yojimbo is that it provides different content types in its posts (e.g. bookmarks, web archives, passwords, serial numbers and notes). As soon as I saw the bookmark option, I immediately started searching for a way to import all my del.icio.us bookmarks into Yojimbo. Unfortunately, I didn’t find anything, so I decided to write an import script.

The first thing I did was install RubyOSA, a gem that provides a bridge from Ruby to the Apple Event Manager. It allows Ruby programs to automate Mac OS X applications in the same way as AppleScript.

Code (shell)
  1. $ sudo gem install rubyosa

After that I went to the following URL to download all of my del.icio.us links into a single XML file:

https://api.del.icio.us/v1/posts/all (you’ll be prompted for your del.icio.us username and password) Once you see your bookmarks, go to file->save and save the file as all.xml. Open the xml file you just created and change the second line from this:

<posts update=”2007-05-19T23:44:07Z” user=”username”>

to

<posts>

Then, just use the following script to import your bookmarks from del.icio.us to Yojimbo:

Code (ruby)
  1. require ‘rubygems’
  2. require ‘rbosa’
  3. require ‘xmlsimple’
  4. myconfig =  XmlSimple.xml_in("all.xml", {})
  5. app = OSA.app(‘Yojimbo’)
  6.  
  7. myconfig.each { |posts|
  8.   posts[1].each { |post|
  9.     bookmark = app.make(OSA::Yojimbo::BookmarkItem, with_contents=nil, with_properties=nil)
  10.     bookmark.name=post[‘description’]
  11.     bookmark.location=post[‘href’]
  12.     bookmark.comments=post[‘extended’]
  13.     tags = post[‘tag’].split(/ /)
  14.     tags.each {|t| app.add_tags(t, bookmark)}
  15.   }
  16. }

It’s possible you’ll need to install XmlSimple to get the script working. For some reason, installing the XmlSimple gem wasn’t enough, I had to download version 1.0.6 and run:

Code (shell)
  1. ruby install.rb config
  2. ruby install.rb setup
  3. ruby install.rb install

Good luck.


3 Responses to “Del.icio.us to Yojimbo”

  1. Aaron Says:

    Script works beautifully except when copy and pasting the script, the single quotes need to be replaced (did SmartyPants do this?) or you will get an error.

  2. Mike Says:

    Trying this out but I’m getting the following error when I try to install rubyosa on Leopard:

    Building native extensions. This could take a while…
    ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

    ruby extconf.rb install rubyosa
    can’t find header files for ruby.

    Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/rubyosa-0.4.0 for inspection.
    Results logged to /Library/Ruby/Gems/1.8/gems/rubyosa-0.4.0/gem_make.out

    Sadly I know nothing about Ruby! Any clues?

    Cheers, Mike

  3. Mike Says:

    Ignore my last post… I installed Ruby through Macports and installed rubyosa and xml-simple and now get these errors:

    /opt/local/lib/ruby/gems/1.8/gems/rubyosa-0.4.0/lib/rbosa.rb:773:in `__send_event__’: application returned error: Data could not be coerced to the requested descriptor type (-1700) (RuntimeError)
    from /opt/local/lib/ruby/gems/1.8/gems/rubyosa-0.4.0/lib/rbosa.rb:773:in `make’
    from ./delruby.sh:10
    from ./delruby.sh:9:in `each’
    from ./delruby.sh:9
    from ./delruby.sh:8:in `each’
    from ./delruby.sh:8

    I appreciate you like all of us will be a extremely busy but any feedback would be appreciated so I can get my bookmarks into Yojimbo.

    Cheers,

    Mike

Leave a Reply