Created
January 22, 2017 23:36
-
-
Save crcastle/9b60aa65f39d75f90b46405af3bf7511 to your computer and use it in GitHub Desktop.
Extract Kindle highlights into CSV format for https://crc.io/projects/reading
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 'kindle_highlights' | |
kindle = KindleHighlights::Client.new( | |
email_address: 'amazon@crc.io', | |
password: '', | |
mechanize_options: { user_agent_alias: 'Mac Mozilla' } | |
) | |
puts 'quote_id,quote_link,quote_text,post_title,post_link,post_author,post_author_link,post_site_link,unix_time' | |
kindle.books.each do |asin, title| | |
kindle.highlights_for(asin).each do |h| | |
print "kindle://book?action=open&asin=#{asin}&location=#{h['startLocation']}" | |
print ",\"#{h['highlight']}\"" | |
print ",#{title}" | |
print ",https://www.amazon.com/dp/#{asin}/" | |
print ",author" | |
print ",author_link" | |
print ",post_site_link" | |
puts ",#{h['timestamp']}" | |
end | |
end | |
# for testing individual book | |
=begin | |
kindle.highlights_for("B014NW9SPS").each do |h| | |
puts "\"#{h['highlight']}\",#{h['timestamp']}" | |
end | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment