Skip to content

Instantly share code, notes, and snippets.

@a-chernykh
Created June 15, 2014 17:39
Show Gist options
  • Save a-chernykh/2695eb0dcc844e34123c to your computer and use it in GitHub Desktop.
Save a-chernykh/2695eb0dcc844e34123c to your computer and use it in GitHub Desktop.
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