Skip to content
Browse files

Revert "Revert 50920f8^..HEAD"

This reverts commit c2b88be.
  • Loading branch information...
1 parent c2b88be commit 42cb118333deb9a5ecdf0cdc214f8145e8566e7b @lepht committed Feb 23, 2012
Showing with 47 additions and 31 deletions.
  1. +5 −0 Gemfile
  2. +14 −0 Gemfile.lock
  3. +1 −0 README.md
  4. +27 −31 ril_to_instapaper.rb
View
5 Gemfile
@@ -0,0 +1,5 @@
+source 'http://rubygems.org'
+
+gem 'progressbar'
+gem 'json'
+gem 'highline'
View
14 Gemfile.lock
@@ -0,0 +1,14 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ highline (1.6.11)
+ json (1.6.5)
+ progressbar (0.10.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ highline
+ json
+ progressbar
View
1 README.md
@@ -1,5 +1,6 @@
Transfers all unread links from [ReadItLater](http://readitlaterlist.com) to [Instapaper](http://instapaper.com)
+## Usage ##
Just run `ril_to_instapaper.rb` from the commandline and you will be prompted for your username and password for both services. Your credentials won't be stored anywhere, and must be entered each time you run the script.
All 'unread' links will then be transferred from your ReadItLater account to your Instapaper account, and a result summary is printed.
View
58 ril_to_instapaper.rb
@@ -7,30 +7,28 @@
require 'highline/import'
def get_ril_links(ril_user,ril_pass)
- ril_url = "https://readitlaterlist.com/v2/get?username=#{ril_user}&password=#{ril_pass}&apikey=3b2p1o6aA560xh9611g4540C6bd8YaX4&state=unread"
-
- ril_link_objects = JSON.parse(open(ril_url).read)["list"].values
-
- ril_link_urls = ril_link_objects.collect{|i| i["url"]}
+ ril_url = "https://readitlaterlist.com/v2/get?username=#{ril_user}&password=#{ril_pass}&apikey=3b2p1o6aA560xh9611g4540C6bd8YaX4&state=unread"
+ ril_link_objects = JSON.parse(open(ril_url).read)["list"].values
+ ril_link_urls = ril_link_objects.collect{|i| i["url"]}
end
def add_link_to_instapaper(insta_user, insta_pass, link)
- insta_url = "https://www.instapaper.com/api/add?username=#{insta_user}&url=#{URI.escape(link)}"
- insta_url += "&password=#{insta_pass}" unless insta_pass.empty?
+ insta_url = "https://www.instapaper.com/api/add?username=#{insta_user}&url=#{URI.escape(link)}"
+ insta_url += "&password=#{insta_pass}" unless insta_pass.empty?
- begin
- return open(insta_url).read
- rescue OpenURI::HTTPError => e
- e.io.status[0]
- end
+ begin
+ return open(insta_url).read
+ rescue OpenURI::HTTPError => e
+ e.io.status[0]
+ end
end
def ask_for_user_creds
- @ril_user = ask("ReadItLater username:")
- @ril_pass = ask("ReadItLater password:") {|q| q.echo = false}
+ @ril_user = ask("ReadItLater username:")
+ @ril_pass = ask("ReadItLater password:") {|q| q.echo = false}
- @insta_user = ask("Instapaper username/email address:")
- @insta_pass = ask("Instapaper password (optional):") {|q| q.echo = false}
+ @insta_user = ask("Instapaper username/email address:")
+ @insta_pass = ask("Instapaper password (optional):") {|q| q.echo = false}
end
# Main script execution
@@ -44,26 +42,24 @@ def ask_for_user_creds
progress = ProgressBar.new("Sending links to Instapaper", ril_links.size)
ril_links.each do |link|
- result = add_link_to_instapaper(@insta_user,@insta_pass, link)
-
- progress.inc
-
- case result
- when "201"
- success_count += 1
- else
- failed_urls << link
- end
+ result = add_link_to_instapaper(@insta_user,@insta_pass, link)
+ progress.inc
+ case result
+ when "201"
+ success_count += 1
+ else
+ failed_urls << link
+ end
end
progress.finish
#Print results
puts "Migration complete!
- \tLinks transferred to Instapaper: #{success_count}
- \tLinks failed: #{failed_urls.size}"
+ \tLinks transferred to Instapaper: #{success_count}
+ \tLinks failed: #{failed_urls.size}"
if failed_urls.size > 0 then
- puts "Failed links were: "
- failed_urls.each {|link| puts link}
-end
+ puts "Failed links were: "
+ failed_urls.each {|link| puts link}
+end

0 comments on commit 42cb118

Please sign in to comment.
Something went wrong with that request. Please try again.