Created
May 16, 2009 08:11
-
-
Save bak/112620 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
# delicious2yojimbo.rb by Ben Kerney, [email protected] | |
# Based on delicious2yojimbo.pl by Marcus Kazmierczak, [email protected] | |
# and Manton Reece, http://www.manton.org/, which, when I downloaded it on | |
# 2009-05-16, was not working for me. | |
# Rather than troubleshoot, I rewrote it in Ruby. | |
# TODO: support multi-word tags, report actual success of import | |
# ============================================================================ | |
# A simple script to import del.icio.us bookmarks, with tags, into Yojimbo | |
# No syncing, or any fancy stuff. Intended as a one time deal. | |
# Step 1: | |
# Got to: https://api.del.icio.us/v1/posts/all?user=YOURNAME | |
# Replacing YOURNAME with your del.icio.us username | |
# Login using your del.icio.us account | |
# save file to your desktop called: all.xml | |
# Step 2: | |
# If you haven't done so already, save the delicious2yojimbo | |
# script to your desktop (or same location as all.xml) | |
# Step 3: | |
# From the terminal/x11/command-line run the script | |
# ruby delicious2yojimbo.rb | |
filename = "all.xml" | |
lines = File.new(filename) | |
i = 0 | |
strip = "'" # characters that interfere with the command line | |
lines.each do |line| | |
if line =~ /.*href="(.*?)".*description="(.*?)".*tag="(.*?)".*/i | |
href, desc, tag = $1.tr(strip,""), $2.tr(strip,""), $3.tr(strip,"") | |
puts "#{href} :: #{desc} :: #{tag} \n " | |
as_cmd = "tell application \"Yojimbo\"\n" | |
as_cmd += "set the_item to make new bookmark item with properties {name:\"#{desc}\", location:\"#{href}\", comments:\"\"} \n" | |
as_cmd += "add tags (words of \"#{tag}\") to the_item \n" | |
as_cmd += "end tell" | |
result = `osascript -e '#{as_cmd}'` | |
i += 1 | |
end | |
end | |
puts "Imported #{i} Bookmarks \n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment