You are currently browsing the archives for the "import" tag.

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.