Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import delicious bookmarks from 1 user to another
source 'https://rubygems.org'
gem 'delicious', '~> 1.0.0'
# Import all user2 bookmarks into user1 account
require 'rubygems'
require 'bundler/setup'
require 'delicious'
user1 = Delicious::Client.new do |c|
c.access_token = 'user1-token'
end
user2 = Delicious::Client.new do |c|
c.access_token = 'user2-token'
end
user2.bookmarks.all.each do |bookmark|
tries = 0
begin
tries += 1
puts "Creating #{bookmark}"
user1.bookmarks.create url: bookmark.url,
description: bookmark.description.gsub(/[^0-9A-Za-z\s]/, ''),
extended: bookmark.extended.gsub(/[^0-9A-Za-z\s]/, ''),
tags: bookmark.tags,
dt: bookmark.dt,
shared: bookmark.shared,
replace: true
rescue Delicious::Error => e
# delicious throws 'access denied' errors all the time for no reason
sleep tries * 3
retry if tries < 3
puts
puts "Err ;( #{e.inspect}"
puts
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment