Created
July 27, 2010 20:35
-
-
Save kimjoar/492818 to your computer and use it in GitHub Desktop.
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 'nokogiri' | |
require 'highline/import' | |
require 'instapush' | |
pinboard_username = ask("Enter your Pinboard username: ") { |q| q.echo = true } | |
pinboard_password = ask("Enter your Pinboard password: ") { |q| q.echo = "*" } | |
bookmarks = `wget http://#{pinboard_username}:#{pinboard_password}@pinboard.in/export/` | |
instapaper_username = ask("Enter your Instapaper username: ") { |q| q.echo = true } | |
instapaper_password = ask("Enter your Instapaper password (if you have one): ") { |q| q.echo = "*" } | |
doc = Nokogiri::XML bookmarks | |
instapaper = InstaPush.connect instapaper_username, instapaper_password | |
say "\nAdding links from Pinboard to Instapaper\n\n" | |
doc.css('A').each do |element| | |
if element['TAGS'].split(',').include?('toread') | |
title = element.children.first.content | |
url = element['HREF'] | |
add = ask("Add '#{title}': (y/n) ") { |q| q.default = "y" } | |
next unless add == "y" | |
# Add to Instapaper | |
if instapaper.add url, :title => title | |
say "Added '#{title}' (#{url})" | |
else | |
say "** Failed to add '#{title}' (#{url})" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment