Kindle使いには朗報なアプリケーションですよ。 電子書籍を読むのに最適なリーダーの一つがKindleではないかと思います。その中で提供される機能の一つがテキストを選択して保存するハイライトです。Kindleの中で確認はできますが、再利用性が低いのが難点です。そこで自分のハイライトしたデータをダウンロードできるのがkindle-highlightsです。 現在は残念ながらAPIは公開されていないとのことで、kindle-highlightsはスクレイピングによって目的を達成します。 インストールはRubygemsで簡単にできます。

$ gem install kindle-highlights

使い方もシンプルで、AmazonのID、パスワードを使って実行します。

require 'kindle_highlights'
# pass in your Amazon credentials. Loads your books (not highlights) on init, so might take a while                                                             
kindle = KindleHighlights::Client.new("Amazon.co.jpのID", "パスワード") 

その実行結果は次のようになります。 Mechanizeが入っています。スクレイピングに用いられています。 後はbooksメソッドを実行するとKindleに登録されている書籍データが一覧で返ってきます。

kindle.books #=>
{
  "B002JCSCO8"=>"The Art of the Commonplace: The Agrarian Essays of Wendell Berry",
  "B0049SPHC0"=>"Calvinistic Concept of Culture, The",
  :
  "B0026772N8"=>"Zen and the Art of Motorcycle Maintenance"
}

後はその書籍ID(いわゆるASIN)を指定するとハイライト箇所が得られる仕組みです。

kindle.highlights_for("B005CQ2ZE6") #=>
[
  {
    "asin"=>"B005CQ2ZE6",
    "customerId"=>"...",
    "embeddedId"=>"From_the_Garden_to_the_City:420E805A",
    "endLocation"=>29591,
    "highlight"=>"One of the most dangerous things you can believe in this world is that technology is neutral.",
    "howLongAgo"=>"1 year ago",
    "startLocation"=>29496,
    "timestamp"=>1320901233000
  },
  {
    "asin"=>"B005CQ2ZE6",
    "customerId"=>"...",                                    
    "embeddedId"=>"From_the_Garden_to_the_City:420E805A",
    "endLocation"=>54220,
    "highlight"=>"While God's words are eternal and unchanging, the tools we use to access those words do change, and those changes in technology also bring subtle changes to the practice of worship. When we fail to recognize the impact of such technological change, we run the risk of allowing our tools to dictate our methods. Technology should not dictate our values or our methods. Rather, we must use technology out of our convictions and values.",
    "howLongAgo"=>"1 year ago",
    "startLocation"=>53780,
    "timestamp"=>1321038422000
  }
]

書籍の気になる部分をハイライトしておいて、kindle-highlightsで取り出せば後でブログで引用したりするのも簡単にできそうですね。こういったデジタルな再利用ができるのは電子書籍ならではと言えるのではないでしょうか。 電子書籍は実際に読んでみると紙以上に読みたい場所を探すのに時間を要します。ペラペラと素早くめくることができないため、電子書籍はもちろんマンガであってもなかなか思った箇所に辿り着けなかったりします。検索でもなかなかうまくいかないのではないでしょうか。 そのため気になる部分にはとりあえずハイライトを付けておいて、後で一覧で確認できるようになっていれば探す手間が省けるかも知れません。書籍は一度読んで終わりではなく、再利用しなければ勿体ないです。電子書籍ならではの再利用性向上を考えてみましょう。 kindle-highlightsはRuby製、MIT Licenseのオープンソース・ソフトウェアです。 speric/kindle-highlights