Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extract Kindle highlights into CSV format for https://crc.io/projects/reading
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
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