Giter VIP home page Giter VIP logo

kindle-notebook's Introduction

Kindle Notebook

Fetch your Kindle Highlights along with their context using the Selenium Webdriver

Gem Version

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add kindle-notebook

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install kindle-notebook

Configuration

You can either create a .env file and add your credentials, the default values will be fetched from this file, or configure the gem, for example in an initializer file.

KindleNotebook.configure do |config|
  config.url = "https://read.amazon.com/"
  config.login = ENV["AMAZON_EMAIL"]
  config.password = ENV["AMAZON_PASSWORD"]
  config.selenium_driver = :firefox
  config.headless_mode = false
  config.min_highlight_words = 1
  config.max_highlight_words = 3
end

The configuration options min_highlight_words and max_highlight_words determine the range for a highlight's word count. Highlights with a word count outside this range will not be considered will be filtered out.

Usage

Sign in:

client = KindleNotebook::Client.new
client.sign_in

Get the highlights from a book:

books = client.books
book = books.first
book.fetch_highlights
book.highlights

To write to a CSV file:

book.to_csv_file # => "Docker: A Project-Based Approach to Learning - Cannon, Jason.csv"

Examples

Book:

#<KindleNotebook::Book:0x00007f0847c4e388
  @asin="B09FJ3411G",
  @author="Cannon, Jason",
  @highlights=[#<KindleNotebook::Highlight:0x00007f46959d61f0 @book_asin="B09FJ3411G", ...],
  @highlights_count=13,
  @title="Docker: A Project-Based Approach to Learning">

Highlight:

#<KindleNotebook::Highlight:0x00007f46959d61f0
  @book_asin="B09FJ3411G",
  @context="If you get stuck, the logging component of systemd, called journald, can also help.",
  @page="120",
  @raw_context="used, for example. If you get stuck, the logging component of systemd, called journald, can also help. This journald command displays the last 20 entries in the",
  @raw_text="journald,",
  @text="journald">

Book CSV:

text,page,context,book_asin,raw_text,raw_context
journald,120,"If you get stuck, the logging component of systemd, called journald, can also help.",B09FJ3411G,"journald,","used, for example. If you get stuck, the logging component of systemd, called journald, can also help. This journald command displays the last 20 entries in the"
swarm,225,"Docker Swarm In this chapter, you're going to learn how to create and use a Docker",B09FJ3411G,swarm.,"Docker Swarm In this chapter, you're going to learn how to create and use a Docker"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Testing

This gem is using puffing-billy for testing which needs the geckodriver executable. It can be installed with:

$ sudo apt-get install firefox-geckodriver # or
$ brew install geckodriver

The executable should be in your PATH, if it is not you can run the following command (please adapt the location of the geckodriver executable with yours):

$ echo 'export PATH=$PATH:/home/user/.cache/selenium/geckodriver/linux64/0.33.0' >> ~/.zshrc

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/b1anca/kindle-notebook. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the KindleNotebook project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

kindle-notebook's People

Contributors

b1anca avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.