Giter Club home page Giter Club logo

legimi-go's Introduction

legimi-go

Simple, alternative downloader of Legimi ebooks written in Go.

Basically, a rewrite of previous downloader in Lua.

It is completely unofficial, I am not affiliated with Legimi in any way.

Note

This is still work in progress, however, it is already usable.

You can find more information about how it came about in Background.

Installation

Simply download archive from Releases section, unpack and make it executable (if needed): $ chmod +x legimi-go. You can add installation directory to your PATH variable to be able to run it from anywhere, of course.

Alternatively, if you have Go installed, you can install it using go install command:

$ go install github.com/tp86/legimi-go@<version>

<version> can be specific version tag from releases or latest to get code from main branch. Note that main branch may contain unfinished features. I'm doing my best to commit only working code, though.

Usage

To view usage, invoke:

$ legimi-go --help

Options

All command line switches are optional.

  • --config path

    Path to configuration file. Default value is "$HOME/.config/legimi-go/config.ini". Configuration file contains your credentials and Kindle Id as assigned by Legimi service. It will be automatically created (with missing directories) on first command run, so generally you don't need to modify it by hand. If you don't want to store your login and password in file, you can provide credentials in command line (see --login and --password switches).

Tip

You can create many configuration files so you can easily switch between multiple accounts.

  • --login login

    Your Legimi login. If you don't provide login from command line, it will be read from configuration file. If it is missing in configuration file as well, you will be asked to provide it during command execution. It will be then stored in configuration file, so you don't have to repeat it during future command runs. If you do provide login from command line, it will not be written to configuration file.

  • --password password

    Your Legimi password. Same logic as for login applies. Note that login and password are stored in configuration file as plain text.

  • --debug

    Enable debugging mode. In debugging mode, selected information about exchanged requests and responses is printed to stderr. Currently, probably the most useful information is contained within session response.

Note

You can give switches with one (-config) or two dashes (--config).

Commands

Available commands are:

  • list

    List books currently on your Legimi shelf.

  • download <id> ...

    Download book(s) given their id(s). Book id can be obtained by listing books (first value in book entry line).

  • version

    Print legimi-go version.

Providing command is mandatory, there is no default command.

On the first command invocation, you will be prompted to provide credentials (if not given via command line switches, see above) and Kindle Serial Number (Settings -> Device Options -> Device Info in Kindle). Legimi Kindle Id will be automatically queried and stored in configuration file for future use.

Basic usage scenario

  1. List books on your shelf

    $ legimi-go list

    If you're running script for the first time, or passing configuration file that does not have credentials yet, you will be prompted for login and password.

  2. Download selected book(s)

    $ legimi-go download <book-id>

    Downloaded book will be saved to <book-id>.mobi file in current working directory.

Tip

You can cd into mounted Kindle's documents directory before downloading to avoid copying files.

  1. Copy files to your Kindle's documents directory

    This is optional if you have downloaded books while in documents directory.

Limitations

Obviously, only subset of functionality of official Legimi app is supported.

Most error responses are not recognized / handled yet. This should improve in the future.

Script is not intended to create account or register device unknown to the Legimi service. You should use official app for this. Device registration works, but may cause issues.

If you want to know how many book downloads are left in subscription period, you can use -debug switch and look for downloads left information under Session response section. If you are trying to download more books than you limit, Legimi service will block downloads.

Troubleshooting

If something is not working as expected, try to use -debug switch to get more information.

Official Legimi app should be checked also, as it is a reference point. Using official app can also potentially fix issues (#3 (comment)).

Background

Official Legimi app does not support Linux. I wanted to be able to download ebooks from Linux without the need to switch between OSes (or even have Windows installed).

First version of downloader was created in Lua. It worked fine, but proved to be hard to install sometimes (dependencies installed to different paths). It is also hard to maintain and it causes issues with Legimi protocol updates. Therefore, I decided to rewrite script in Go. I hope it will be easier to install, use and maintain.

I extracted the logic of downloading books based on traffic exchanged between official Legimi application and service. As such, there are certainly missing pieces and features. Also, most error responses are not supported. See Limitations for more missing features.

TODO

  • handle more error responses from Legimi service
  • refactors
  • documentation update
  • increase test coverage
  • reuse session id if possible
  • parallel downloader
  • handle occassional EOF while getting list of books
  • option to specify directory for downloaded books

legimi-go's People

Contributors

tp86 avatar

Stargazers

 avatar Skidam avatar  avatar Konrad Szwedo avatar  avatar

Watchers

 avatar  avatar

legimi-go's Issues

legimi-go list - no books listed

Hello,
Despite the fact, that I have added books on the shelf in the legimi, when I use legimi-go list command, I don't receive any results.
I have used your old legimi app written in lua and it worked perfectly, but now I experience the same issue in the lua and the go implementations.

Fantastic job!

Hello again!
First - well done, nice, clean, and quite clever.
Code works, download works, issue with:
legimi-go list -> on OSx: most of attempts gave "Error while executing command: decoding error: EOF"
For second account it will not load the list at all (but will download) as book id's seem to be the same (as I accidentally tested it).
All the best,

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.