Skip to content
Browse files

Revert 50920f8^..HEAD

  • Loading branch information...
1 parent 8dfc5a5 commit c2b88be24a1172805eb4112db075bb3c38382105 @lepht committed Feb 23, 2012
Showing with 31 additions and 47 deletions.
  1. +0 −5 Gemfile
  2. +0 −14 Gemfile.lock
  3. +0 −1 README.md
  4. +31 −27 ril_to_instapaper.rb
View
5 Gemfile
@@ -1,5 +0,0 @@
-source 'http://rubygems.org'
-
-gem 'progressbar'
-gem 'json'
-gem 'highline'
View
14 Gemfile.lock
@@ -1,14 +0,0 @@
-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,6 +1,5 @@
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,28 +7,30 @@
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
@@ -42,24 +44,26 @@ 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 c2b88be

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