Last active
August 29, 2015 14:01
-
-
Save dommmel/54bea24e2d890c240c4f to your computer and use it in GitHub Desktop.
import any delicious user's bookmarks into pinboard (limited to the last 100 bookmarks)
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
require "pinboard" | |
require 'net/https' | |
require "uri" | |
require "json" | |
username = "pinboard_username" | |
password = "pinboard_password" | |
delicious_user = "delicious_username" | |
pinboard = Pinboard::Client.new(:username => username, :password => password) | |
# Get data from delicious | |
uri = URI.parse("https://previous.delicious.com/v2/json/#{delicious_user}?count=100") | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
request = Net::HTTP::Get.new(uri.request_uri) | |
response = http.request(request) | |
delicious_bookmarks = JSON.parse(response.body) | |
# import bookmarks into pinboard | |
delicious_bookmarks.each do |bm| | |
sleep 3 # Don#t annoy the pinboard api | |
puts pinboard.add(:url => bm['u'], :description => bm['d'],:dt => bm['dt'], :tags => bm['t']) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment