Import delicious bookmarks from 1 user to another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'delicious', '~> 1.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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