Last active
May 22, 2018 00:39
-
-
Save goldeneggg/81d57499aa09790c53f503df7700e51c to your computer and use it in GitHub Desktop.
Kindle highlights to markdown for amazon.co.jp
This file contains hidden or 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
# Note: | |
# tagged version of kindle-highlights gem is not supported "root_url" option. | |
# So should use "master" branch version. | |
require "kindle_highlights" | |
puts "START kindle highlights output to markdown" | |
kindle = KindleHighlights::Client.new(email_address: ENV['KINDLE_EMAIL'], password: ENV['KINDLE_PASSWD'], root_url: 'https://read.amazon.co.jp') | |
kindle.books.each_with_index do |book, i| | |
puts "========== TITLE: #{book.title}" | |
hs = kindle.highlights_for(book.asin) | |
puts "highlight count: #{hs.size}" | |
path = "#{book.title}.md" | |
File.delete(path) if File.exists?(path) | |
File.open(path, "a") do |f| | |
f.puts("# kindle highlight: #{book.title}") | |
f.puts("") | |
hs.each do |h| | |
f.puts("* #{h.location}: #{h.text}") | |
end | |
f.puts("") | |
f.puts("") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment