Skip to content

Instantly share code, notes, and snippets.

@reidab
Created September 27, 2011 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reidab/1246220 to your computer and use it in GitHub Desktop.
Save reidab/1246220 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Delicious' export functionality currently exports a file that says
# all of your bookmarks were added at the current time, instead of the
# actual times when you saved them.
#
# This is annoying.
#
# This script will generate a compatible export file that has the correct dates.
#
# WARNING: The library I'm using to talk to delicious, Mirrored, doesn't seem to
# support delicious' private bookmark flag. It has a "share" attribute, but this
# always seems to come back as yes, so if you use private bookmarks you probably
# don't want to use this for anything that matters.
#
# Usage:
# - install mirrored: `gem install mirrored`
# - run this script: `USER=yourusername PASS=yourpassword ruby delicious_export.rb`
USER = ENV['USER']
PASS = ENV['PASS']
require 'mirrored'
Mirrored::Base.establish_connection(:delicious, USER, PASS)
puts %Q{<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>}
offset = 0
loop do
posts = Mirrored::Post.find(:all, :start => offset)
offset += 1000
break if posts == []
posts.each do |post|
puts %Q{<DT><A HREF="#{post.href}" ADD_DATE="#{post.time.to_i}" PRIVATE="#{post.share == 'yes' ? 0 : 1}" TAGS="#{post.tags.join(',')}">#{post.description}</A>}
puts %Q{<DD>#{post.extended}} unless post.extended == ""
end
end
puts "</DL><p>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment