bak (owner)

Revisions

gist: 112620 Download_button fork
public
Public Clone URL: git://gist.github.com/112620.git
Embed All Files: show embed
delicious2yojimbo.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env ruby -w
 
# delicious2yojimbo.rb by Ben Kerney, ben.kerney@gmail.com
 
# Based on delicious2yojimbo.pl by Marcus Kazmierczak, marcus@mkaz.com
# 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"