Skip to content

Instantly share code, notes, and snippets.

@goldeneggg

goldeneggg/kh2md.rb

Last active May 22, 2018
Embed
What would you like to do?
Kindle highlights to markdown for amazon.co.jp
# 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
You can’t perform that action at this time.