Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/speric/kindle-highlights
Get your Kindle highlights.
https://github.com/speric/kindle-highlights
books kindle reading
Last synced: about 1 month ago
JSON representation
Get your Kindle highlights.
- Host: GitHub
- URL: https://github.com/speric/kindle-highlights
- Owner: speric
- License: mit
- Created: 2011-12-20T15:54:17.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2020-04-04T01:12:01.000Z (over 4 years ago)
- Last Synced: 2024-04-26T22:03:21.647Z (8 months ago)
- Topics: books, kindle, reading
- Language: Ruby
- Homepage: https://rubygems.org/gems/kindle-highlights
- Size: 48.8 KB
- Stars: 568
- Watchers: 16
- Forks: 51
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
- my-awesome-github-stars - speric/kindle-highlights - Get your Kindle highlights. (Ruby)
README
## kindle-highlights
[![build status](https://secure.travis-ci.org/speric/kindle-highlights.png)](http://travis-ci.org/speric/kindle-highlights)
A Ruby gem for collecting your Kindle highlights.
### Requirements
* Ruby `2.1.0` or greater
* An Amazon Kindle account### Install
```
gem install kindle-highlights
```### Use
First, `require` the gem and initialize a new client by passing in the email address & password you use
to sign into your Amazon Kindle account:```ruby
require 'kindle_highlights'kindle = KindleHighlights::Client.new(
email_address: "[email protected]",
password: "password"
)
```### Fetching a list of your Kindle books
Use the `books` method to get a listing of all your Kindle books. This method
returns a collection of `KindleHighlights::Book` objects:```ruby
kindle.books
#=>
[
,
,
]
```Each `Book` object has it's `asin`, `author`, and `title` as attributes:
```ruby
book = kindle.books.first
book.asin
#=> "B000XUAETY"
book.author
#=> "James R. Mcdonough"
book.title
#=> "Platoon Leader: A Memoir of Command in Combat"
```### Fetching all highlights for a single book
To get only the highlights for a specific book, use the `highlights_for` method, passing
in the book's Amazon ASIN as the only method parameter. This method returns a collection of
`KindleHighlights::Highlight` objects:```ruby
kindle.highlights_for("B005CQ2ZE6")
#=>
[
]
```Each `Highlight` object has the book's `asin`, the `text` of the highlight, and it's `location` as attributes:
```ruby
highlight = kindle.highlights_for("B005CQ2ZE6").firsthighlight.asin
#=> "B005CQ2ZE6"
highlight.text
#=> "One of the most dangerous things you can believe in this world is that technology is neutral."
highlight.location
#=> "197"
```Additionally, each book has it's own `highlights_from_amazon` method:
```
book = kindle.books.first
book.highlights_from_amazon
```### Advanced Usage
This gem uses [mechanize](https://github.com/sparklemotion/mechanize) to interact with Amazon's Kindle pages. You can override any of the default mechanize settings (see `lib/kindle_highlights/client.rb`) by passing your settings to the initializer:
```ruby
kindle = KindleHighlights::Client.new(
email_address: "[email protected]",
password: "amazon_password",
mechanize_options: { user_agent_alias: 'Mac Safari' }
)
```Or you can use `read.amazon.com` equivalents provided on other TLDs like:
```ruby
kindle = KindleHighlights::Client.new(
email_address: "[email protected]",
password: "amazon_password",\
root_url: 'https://read.amazon.co.jp'
)
```### A Note About CAPTCHAs
Amazon will sometimes issue a CAPTCHA challenge when logging in to your
Kindle account. If this happens when the gem attempts to log in to your
Kindle account to retrieve your book list or highlights, you'll get a `KindleHighlights::Client::CaptchaError`, like the following:```ruby
> kindle.books
KindleHighlights::Client::CaptchaError: Received a CAPTCHA while attempting to sign in to your Amazon account. You will need to resolve this manually at https://www.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid...
```There's no way to programmatically resolve this situation. The best
solution I've found is to open a browser, visit the URL that the gem returns, log in to
your Kindle account, and click around a bit. Then log out of your Kindle
account and re-attempt to fetch your highlights via this gem. Additionally, you could try
instantiating a new instance of the client and changing the User-Agent
via `mechanize_options` like:```ruby
kindle = KindleHighlights::Client.new(
email_address: "[email protected]",
password: "amazon_password",
mechanize_options: { user_agent_alias: 'iPhone' }
)
```### In The Wild
* [tobi/highlights](https://github.com/tobi/highlights) - Download your Kindle highlights and email random ones to your inbox### Contributing to kindle-highlights (PRs welcome)
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the [issue tracker](http://github.com/speric/kindle-highlights/issues) to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for the feature/bugfix. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate it to its own commit so I can cherry-pick around it.### Copyright
Copyright (c) 2011-2018 Eric Farkas. See MIT-LICENSE for details.