Git Product home page Git Product logo

audible-cli's Introduction

audible-cli

audible-cli is a command line interface for the Audible package. Both are written with Python.

Requirements

audible-cli needs at least Python 3.6 and Audible v0.5.3.

It depends on the following packages:

  • aiofiles
  • audible
  • click
  • colorama (on windows machines)
  • httpx
  • Pillow
  • tabulate
  • toml
  • tqdm

Installation

This package is not on PyPi at this moment. To install audible-cli you have to clone it from this repo.

git clone https://github.com/mkb79/audible-cli.git
cd audible-cli
pip install .

Tab Completion

Tab completion can be provided for commands, options and choice values. Bash, Zsh and Fish are supported. More information can be found here.

Basic information

App dir

audible-cli use an app dir where it expects all necessary files.

If the AUDIBLE_CONFIG_DIR environment variable is set, it uses the value as config dir. Otherwise, it will use a folder depending on the operating system.

OS Path
Windows C:\Users\<user>\AppData\Local\audible
Unix ~/.audible
Mac OS X ~/.audible

The config file

The config data will be stored in the toml format as config.toml.

It has a main section named APP and sections for each profile created named profile.<profile_name>

profiles

audible-cli make use of profiles. Each profile contains the name of the corresponding auth file and the country code for the audible marketplace. If you have audiobooks on multiple marketplaces, you have to create a profile for each one with the same auth file.

In the main section of the config file, a primary profile is defined. This profile is used, if no other is specified. You can call audible -P PROFILE_NAME, to select another profile.

auth files

Like the config file, auth files are stored in the config dir too. If you protected your auth file with a password call audible -p PASSWORD, to provide the password.

If the auth file is encrypted, and you don’t provide the password, you will be asked for it with a „hidden“ input field.

Getting started

Use the audible-quickstart or audible quickstart command in your shell to create your first config, profile and auth file. audible-quickstart runs on the interactive mode, so you have to answer multiple questions to finish.

Commands

Call audible -h to let you show all main subcommands. At this time, there are the activation_bytes, download, library and manage subcommands. The manage command has multiple subcommands. So take a look with the audible manage -h and audible manage <subcommand> -h.

Plugins

Plugin Folder

If the AUDIBLE_PLUGIN_DIR environment variable is set, it uses the value as location for the plugin dir. Otherwise, it will use a the plugins subdir of the app dir. Read above how Audible-cli searches the app dir.

Custom Commands

You can provide own subcommands and execute them with audible SUBCOMMAND. All plugin commands must be placed in the plugin folder. Every subcommand must have his own file. Every file have to be named cmd_{SUBCOMMAND}.py. Each subcommand file must have a function called cli as entrypoint. This function have to be decorated with @click.group(name="GROUP_NAME") or
@click.command(name="GROUP_NAME").

Relative imports in the command files doesn't work. So you have to work with absolute imports. Please take care about this. If you have any issues with absolute imports please add your plugin path to the PYTHONPATH variable or add this lines of code to the begining of your command script:

import sys
import pathlib
sys.path.insert(0, str(pathlib.Path(__file__).parent))

Examples can be found here.

Own Plugin Packages

If you want to develop a complete plugin package for audible-cli you can do this on an easy way. You only need to register your sub-commands or sub-groups to an entry-point in your setup.py that is loaded by the core package.

Example for a setup.py

from setuptools import setup

setup(
    name="yourscript",
    version="0.1",
    py_modules=["yourscript"],
    install_requires=[
        "click",
        "audible_cli"
    ],
    entry_points="""
        [audible.cli_plugins]
        cool_subcommand=yourscript.cli:cool_subcommand
        another_subcommand=yourscript.cli:another_subcommand
    """,
)

Command priority order

Commands will be added in the following order:

  1. plugin dir commands
  2. plugin packages commands
  3. build-in commands

If a command is added, all further commands with the same name will be ignored. This enables you to "replace" build-in commands very easy.

audible-cli's People

Contributors

eode avatar mkb79 avatar tristan avatar

Watchers

 avatar  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.