# audible-cli
**audible-cli** is a command line interface for the
[Audible](https://github.com/mkb79/Audible) package.
Both are written with Python.
## Requirements
audible-cli needs at least *Python 3.6* and *Audible v0.6.0*.
It depends on the following packages:
* aiofiles
* audible
* click
* colorama (on Windows machines)
* httpx
* Pillow
* tabulate
* toml
* tqdm
## Installation
You can install audible-cli from pypi with
```shell
pip install audible-cli
```
or install it directly from GitHub with
```shell
git clone https://github.com/mkb79/audible-cli.git
cd audible-cli
pip install .
```
or as the best solution using [pipx](https://pipx.pypa.io/stable/)
```shell
pipx install audible-cli
```
## Standalone executables
If you don't want to install `Python` and `audible-cli` on your machine, you can
find standalone exe files below or on the [releases](https://github.com/mkb79/audible-cli/releases)
page (including beta releases). At this moment Windows, Linux and macOS are supported.
### Links
1. Linux
- [ubuntu latest onefile](https://github.com/mkb79/audible-cli/releases/latest/download/audible_linux_ubuntu_latest.zip)
- [ubuntu 20.04 onefile](https://github.com/mkb79/audible-cli/releases/latest/download/audible_linux_ubuntu_20_04.zip)
2. macOS
- [macOS latest onefile](https://github.com/mkb79/audible-cli/releases/latest/download/audible_mac.zip)
- [macOS latest onedir](https://github.com/mkb79/audible-cli/releases/latest/download/audible_mac_dir.zip)
3. Windows
- [Windows onefile](https://github.com/mkb79/audible-cli/releases/latest/download/audible_win.zip)
- [Windows onedir](https://github.com/mkb79/audible-cli/releases/latest/download/audible_win_dir.zip)
On every execution, the binary code must be extracted. On Windows machines this can result in a long start time. If you use `audible-cli` often, I would prefer the `directory` package for Windows!
### Creating executables on your own
You can create them yourself this way
```shell
git clone https://github.com/mkb79/audible-cli.git
cd audible-cli
pip install .[pyi]
# onefile output
pyinstaller --clean -F --hidden-import audible_cli -n audible -c pyi_entrypoint
# onedir output
pyinstaller --clean -D --hidden-import audible_cli -n audible -c pyi_entrypoint
```
### Hints
There are some limitations when using plugins. The binary maybe does not contain
all the dependencies from your plugin script.
## 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](https://github.com/mkb79/audible-cli/tree/master/utils/code_completion).
## 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](https://github.com/toml-lang/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.
### Config options
An option in the config file is separated by an underline. In the CLI prompt,
an option must be entered with a dash.
#### APP section
The APP section supports the following options:
- primary_profile: The profile to use, if no other is specified
- filename_mode: When using the `download` command, a filename mode can be
specified here. If not present, "ascii" will be used as default. To override
these option, you can provide a mode with the `filename-mode` option of the
download command.
#### Profile section
- auth_file: The auth file for this profile
- country_code: The marketplace for this profile
- filename_mode: See APP section above. Will override the option in APP section.
## 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.
If you have used `audible quickstart` and want to add a second profile, you need to first create a new authfile and then update your config.toml file.
So the correct order is:
1. add a new auth file using your second account using `audible manage auth-file add`
2. add a new profile to your config and use the second auth file using `audible manage profile add`
## Commands
Call `audible -h` to show the help and a list of all available subcommands. You can show the help for each subcommand like so: `audible <subcommand> -h`. If a subcommand has another subcommands, you csn do it the same way.
At this time, there the following buildin subcommands:
- `activation-bytes`
- `api`
- `download`
- `library`
- `export`
- `list`
- `manage`
- `auth-file`
- `add`
- `remove`
- `config`
- `edit`
- `profile`
- `add`
- `list`
- `remove`
- `quickstart`
- `wishlist`
- `export`
- `list`
- `add`
- `remove`
## Example Usage
To download all of your audiobooks in the aaxc format use:
```shell
audible download --all --aaxc
```
To download all of your audiobooks after the Date 2022-07-21 in aax format use:
```shell
audible download --start-date "2022-07-21" --aax --all
```
## Verbosity option
There are 6 different verbosity levels:
- debug
- info
- warning
- error
- critical
By default, the verbosity level is set to `info`. You can provide another level like so: `audible -v <level> <subcommand> ...`.
If you use the `download` subcommand with the `--all` flag there will be a huge output. Best practise is to set the verbosity level to `error` with `audible -v error download --all ...`
## 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 has 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 beginning of your command script:
```python
import sys
import pathlib
sys.path.insert(0, str(pathlib.Path(__file__).parent))
```
Examples can be found
[here](https://github.com/mkb79/audible-cli/tree/master/plugin_cmds).
## 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
subgroups to an entry-point in your setup.py that is loaded by the core
package.
Example for a setup.py
```python
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.
## List of known add-ons for `audible-cli`
- [audible-cli-flask](https://github.com/mkb79/audible-cli-flask)
- [audible-series](https://pypi.org/project/audible-series/)
If you want to add information about your add-on please open a PR or a new issue!
Raw data
{
"_id": null,
"home_page": "https://github.com/mkb79/audible-cli",
"name": "audible-cli",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "Audible, API, async, cli",
"author": "mkb79",
"author_email": "mkb79@hackitall.de",
"download_url": "https://files.pythonhosted.org/packages/82/2d/9f2514dcc80160b0eb054bf114588e6a6b7a1a62a1d9aa82afc349fa4d0c/audible-cli-0.3.1.tar.gz",
"platform": null,
"description": "# audible-cli\n\n**audible-cli** is a command line interface for the \n[Audible](https://github.com/mkb79/Audible) package. \nBoth are written with Python.\n\n## Requirements\n\naudible-cli needs at least *Python 3.6* and *Audible v0.6.0*.\n\nIt depends on the following packages:\n\n* aiofiles\n* audible\n* click\n* colorama (on Windows machines)\n* httpx\n* Pillow\n* tabulate\n* toml\n* tqdm\n\n## Installation\n\nYou can install audible-cli from pypi with\n\n```shell\n\npip install audible-cli\n\n```\n\nor install it directly from GitHub with\n\n```shell\n\ngit clone https://github.com/mkb79/audible-cli.git\ncd audible-cli\npip install .\n\n```\n\nor as the best solution using [pipx](https://pipx.pypa.io/stable/)\n\n```shell\n\npipx install audible-cli\n\n```\n\n## Standalone executables\n\nIf you don't want to install `Python` and `audible-cli` on your machine, you can\nfind standalone exe files below or on the [releases](https://github.com/mkb79/audible-cli/releases) \npage (including beta releases). At this moment Windows, Linux and macOS are supported.\n\n### Links\n\n1. Linux\n - [ubuntu latest onefile](https://github.com/mkb79/audible-cli/releases/latest/download/audible_linux_ubuntu_latest.zip)\n - [ubuntu 20.04 onefile](https://github.com/mkb79/audible-cli/releases/latest/download/audible_linux_ubuntu_20_04.zip)\n\n2. macOS\n - [macOS latest onefile](https://github.com/mkb79/audible-cli/releases/latest/download/audible_mac.zip)\n - [macOS latest onedir](https://github.com/mkb79/audible-cli/releases/latest/download/audible_mac_dir.zip)\n\n3. Windows\n - [Windows onefile](https://github.com/mkb79/audible-cli/releases/latest/download/audible_win.zip)\n - [Windows onedir](https://github.com/mkb79/audible-cli/releases/latest/download/audible_win_dir.zip)\n\nOn every execution, the binary code must be extracted. On Windows machines this can result in a long start time. If you use `audible-cli` often, I would prefer the `directory` package for Windows!\n\n### Creating executables on your own\n\nYou can create them yourself this way\n\n```shell\n\ngit clone https://github.com/mkb79/audible-cli.git\ncd audible-cli\npip install .[pyi]\n\n# onefile output\npyinstaller --clean -F --hidden-import audible_cli -n audible -c pyi_entrypoint\n\n# onedir output\npyinstaller --clean -D --hidden-import audible_cli -n audible -c pyi_entrypoint\n```\n\n### Hints\n\nThere are some limitations when using plugins. The binary maybe does not contain\nall the dependencies from your plugin script. \n\n## Tab Completion\n\nTab completion can be provided for commands, options and choice values. Bash, \nZsh and Fish are supported. More information can be found \n[here](https://github.com/mkb79/audible-cli/tree/master/utils/code_completion).\n\n\n## Basic information\n\n### App dir\n\naudible-cli use an app dir where it expects all necessary files.\n\nIf the ``AUDIBLE_CONFIG_DIR`` environment variable is set, it uses the value \nas config dir. Otherwise, it will use a folder depending on the operating \nsystem.\n\n| OS | Path |\n|----------|-------------------------------------------|\n| Windows | ``C:\\Users\\<user>\\AppData\\Local\\audible`` |\n| Unix | ``~/.audible`` |\n| Mac OS X | ``~/.audible`` |\n\n### The config file\n\nThe config data will be stored in the [toml](https://github.com/toml-lang/toml) \nformat as ``config.toml``.\n\nIt has a main section named ``APP`` and sections for each profile created \nnamed ``profile.<profile_name>``\n\n### profiles\n\naudible-cli make use of profiles. Each profile contains the name of the \ncorresponding auth file and the country code for the audible marketplace. If \nyou have audiobooks on multiple marketplaces, you have to create a profile for \neach one with the same auth file.\n\nIn the main section of the config file, a primary profile is defined. \nThis profile is used, if no other is specified. You can call \n`audible -P PROFILE_NAME`, to select another profile.\n\n### auth files\n\nLike the config file, auth files are stored in the config dir too. If you \nprotected your auth file with a password call `audible -p PASSWORD`, to \nprovide the password.\n\nIf the auth file is encrypted, and you don\u2019t provide the password, you will be \nasked for it with a \u201ehidden\u201c input field. \n\n### Config options\n\nAn option in the config file is separated by an underline. In the CLI prompt,\nan option must be entered with a dash.\n\n#### APP section\n\nThe APP section supports the following options:\n- primary_profile: The profile to use, if no other is specified\n- filename_mode: When using the `download` command, a filename mode can be \n specified here. If not present, \"ascii\" will be used as default. To override\n these option, you can provide a mode with the `filename-mode` option of the\n download command.\n\n#### Profile section\n\n- auth_file: The auth file for this profile\n- country_code: The marketplace for this profile\n- filename_mode: See APP section above. Will override the option in APP section.\n\n## Getting started\n\nUse the `audible-quickstart` or `audible quickstart` command in your shell \nto create your first config, profile and auth file. `audible-quickstart` \nruns on the interactive mode, so you have to answer multiple questions to finish.\n\nIf you have used `audible quickstart` and want to add a second profile, you need to first create a new authfile and then update your config.toml file.\n\nSo the correct order is:\n\n 1. add a new auth file using your second account using `audible manage auth-file add`\n 2. add a new profile to your config and use the second auth file using `audible manage profile add`\n\n\n## Commands\n\nCall `audible -h` to show the help and a list of all available subcommands. You can show the help for each subcommand like so: `audible <subcommand> -h`. If a subcommand has another subcommands, you csn do it the same way.\n\nAt this time, there the following buildin subcommands: \n\n- `activation-bytes`\n- `api`\n- `download`\n- `library`\n - `export`\n - `list`\n- `manage`\n - `auth-file`\n - `add`\n - `remove`\n - `config`\n - `edit`\n - `profile`\n - `add`\n - `list`\n - `remove`\n- `quickstart`\n- `wishlist`\n - `export`\n - `list`\n - `add`\n - `remove`\n\n## Example Usage\n\nTo download all of your audiobooks in the aaxc format use:\n```shell\naudible download --all --aaxc\n```\nTo download all of your audiobooks after the Date 2022-07-21 in aax format use: \n```shell\naudible download --start-date \"2022-07-21\" --aax --all\n```\n\n## Verbosity option\n\nThere are 6 different verbosity levels:\n\n- debug\n- info\n- warning\n- error\n- critical\n\nBy default, the verbosity level is set to `info`. You can provide another level like so: `audible -v <level> <subcommand> ...`.\n\nIf you use the `download` subcommand with the `--all` flag there will be a huge output. Best practise is to set the verbosity level to `error` with `audible -v error download --all ...`\n\n## Plugins\n\n### Plugin Folder\n\nIf the ``AUDIBLE_PLUGIN_DIR`` environment variable is set, it uses the value \nas location for the plugin dir. Otherwise, it will use a the `plugins` subdir \nof the app dir. Read above how Audible-cli searches the app dir.\n\n### Custom Commands\n\nYou can provide own subcommands and execute them with `audible SUBCOMMAND`.\nAll plugin commands must be placed in the plugin folder. Every subcommand must \nhave his own file. Every file have to be named ``cmd_{SUBCOMMAND}.py``. \nEach subcommand file must have a function called `cli` as entrypoint. \nThis function has to be decorated with ``@click.group(name=\"GROUP_NAME\")`` or \n``@click.command(name=\"GROUP_NAME\")``.\n\nRelative imports in the command files doesn't work. So you have to work with \nabsolute imports. Please take care about this. If you have any issues with \nabsolute imports please add your plugin path to the `PYTHONPATH` variable or \nadd this lines of code to the beginning of your command script:\n\n```python\nimport sys\nimport pathlib\nsys.path.insert(0, str(pathlib.Path(__file__).parent))\n```\n\nExamples can be found \n[here](https://github.com/mkb79/audible-cli/tree/master/plugin_cmds).\n\n\n## Own Plugin Packages\n\nIf you want to develop a complete plugin package for ``audible-cli`` you can\ndo this on an easy way. You only need to register your sub-commands or \nsubgroups to an entry-point in your setup.py that is loaded by the core \npackage.\n\nExample for a setup.py\n\n```python\nfrom setuptools import setup\n\nsetup(\n name=\"yourscript\",\n version=\"0.1\",\n py_modules=[\"yourscript\"],\n install_requires=[\n \"click\",\n \"audible_cli\"\n ],\n entry_points=\"\"\"\n [audible.cli_plugins]\n cool_subcommand=yourscript.cli:cool_subcommand\n another_subcommand=yourscript.cli:another_subcommand\n \"\"\",\n)\n```\n\n## Command priority order\n\nCommands will be added in the following order:\n\n1. plugin dir commands\n2. plugin packages commands\n3. build-in commands\n\nIf a command is added, all further commands with the same name will be ignored.\nThis enables you to \"replace\" build-in commands very easy.\n\n## List of known add-ons for `audible-cli`\n\n- [audible-cli-flask](https://github.com/mkb79/audible-cli-flask)\n- [audible-series](https://pypi.org/project/audible-series/)\n\nIf you want to add information about your add-on please open a PR or a new issue!\n",
"bugtrack_url": null,
"license": "AGPL",
"summary": "Command line interface (cli) for the audible package.",
"version": "0.3.1",
"project_urls": {
"Documentation": "https://audiblecli.readthedocs.io/",
"Homepage": "https://github.com/mkb79/audible-cli",
"Source": "https://github.com/mkb79/Audible-cli"
},
"split_keywords": [
"audible",
" api",
" async",
" cli"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "77fe21e7ab917a5a410e13e7f5673938845459c2871c4116a0f2adefe0451f64",
"md5": "672b3c9c1ae92ee12ab290e6923ecdbe",
"sha256": "d169bcc3dc115aa3e3b436d8393f0238109507e4beeb29cd5f00948e76539c24"
},
"downloads": -1,
"filename": "audible_cli-0.3.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "672b3c9c1ae92ee12ab290e6923ecdbe",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6",
"size": 58481,
"upload_time": "2024-03-19T22:28:09",
"upload_time_iso_8601": "2024-03-19T22:28:09.058066Z",
"url": "https://files.pythonhosted.org/packages/77/fe/21e7ab917a5a410e13e7f5673938845459c2871c4116a0f2adefe0451f64/audible_cli-0.3.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "822d9f2514dcc80160b0eb054bf114588e6a6b7a1a62a1d9aa82afc349fa4d0c",
"md5": "fb8084c0786da40a1a96d0fe96fdcbe5",
"sha256": "e4b712d3a3f0bd74c39048a277704c5bff0590c3c914c54644a295326eadb241"
},
"downloads": -1,
"filename": "audible-cli-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "fb8084c0786da40a1a96d0fe96fdcbe5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 54237,
"upload_time": "2024-03-19T22:28:10",
"upload_time_iso_8601": "2024-03-19T22:28:10.740630Z",
"url": "https://files.pythonhosted.org/packages/82/2d/9f2514dcc80160b0eb054bf114588e6a6b7a1a62a1d9aa82afc349fa4d0c/audible-cli-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-19 22:28:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mkb79",
"github_project": "audible-cli",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "audible-cli"
}