Skip to content

Instantly share code, notes, and snippets.

@ecerulm
Created August 3, 2010 07:11
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ecerulm/505979 to your computer and use it in GitHub Desktop.
require "rubygems"
require "rbosa"
require "cgi"
require "htmlentities"
require 'iconv'
OSA.utf8_strings = true
evernote = OSA.app('Evernote')
coder = HTMLEntities.new
i=1
url = nil
add_date = nil
title = nil
last_visit = nil
tags = nil
notes = ""
File.new("delicious-20090807.htm").each{|line|
#next unless i >2261
if line =~ /<DT><A HREF="(.*)" LAST_VISIT="(.*)" ADD_DATE="(.*)" TAGS="(.*)">(.*)<\/A>$/
if url
#puts "#{i} url:#{url} add:#{Time.at(add_date.to_i)} last:#{Time.at(last_visit.to_i)} tags:#{tags} title:#{title} notes:#{notes}"
#title = CGI.escapeHTML(title)
#notes = CGI.escapeHTML(notes)
#titleunencoded = Iconv.conv("UTF-8","ISO-8859-1",title)
titleunencoded = title[0,254]
title = coder.encode(title,:named)
notes = coder.encode(notes,:named)
tags = coder.encode(tags,:named)
body = "h1. #{title}
body += "p. <a href=\"#{url}\">#{title}</a>
body += "h2. tags
body += "p. #{tags}
body += "h2. description and notes
body += "p. #{notes}
body += "h2. dates
body += "p. add date: #{Time.at(add_date.to_i)}
body += "p. last visit date: #{Time.at(last_visit.to_i)}
puts body
notehandle = evernote.create_note(:with_html => body, :title => titleunencoded, :notebook => "del2" )
notehandle.source_url = url
i += 1
url,last_visit,add_date,tags,title,notes = nil,nil,nil,nil,nil,""
end
url,last_visit,add_date,tags,title = $1, $2, $3, $4, $5
else
notes += line unless url.nil?
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment