Created
October 10, 2016 21:48
-
-
Save jnv/19885e51bf0c566c7b48374678ae7976 to your computer and use it in GitHub Desktop.
Mass management of Instapaper articles in Ruby
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
# frozen_string_literal: true | |
source 'https://rubygems.org' | |
gem 'instapaper', '~> 1.0.0.pre3' |
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
#!/usr/bin/env ruby | |
require 'instapaper' | |
require_relative 'secrets' | |
credentials = { | |
consumer_key: CONSUMER_KEY, | |
consumer_secret: CONSUMER_SECRET, | |
} | |
client = Instapaper::Client.new(credentials) | |
token = client.access_token(USERNAME, PASSWORD) | |
client.oauth_token = token.oauth_token | |
client.oauth_token_secret = token.oauth_token_secret | |
client.verify_credentials | |
## Move all articles to folder | |
FOLDER_FROM = 'unread' | |
FOLDER_TO = '12345' | |
p client.folders | |
begin | |
i = 0 | |
client.bookmarks(limit: 500, folder_id: FOLDER_FROM).each do |bookmark| | |
i += 1 | |
id = bookmark.bookmark_id | |
client.move_bookmark(id, FOLDER_TO) | |
puts "#{i} #{bookmark.title}" | |
end | |
puts "#{i} bookmarks processed" | |
rescue Instapaper::Error => e | |
p e | |
raise | |
end |
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
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
USERNAME = '' | |
PASSWORD = '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment