Package: audible-cli
audible-cliaudible-cliis a command line interface for theAudiblepackage.
Both are written with Python.Requirementsaudible-cli needs at leastPython 3.6andAudible v0.6.0.It depends on the following packages:aiofilesaudibleclickcolorama (on Windows machines)httpxPillowtabulatetomltqdmInstallationYou can install audible-cli from pypi withpipinstallaudible-clior install it directly from GitHub withgitclonehttps://github.com/mkb79/audible-cli.gitcdaudible-cli
pipinstall.Standalone executablesIf you don't want to installPythonandaudible-clion your machine, you can
find standalone exe files below or on thereleasespage (including beta releases). At this moment Windows, Linux and macOS are supported.LinksLinuxubuntu latest onefileubuntu 20.04 onefilemacOSmacOS latest onefilemacOS latest onedirWindowsWindows onefileWindows onedirOn every execution, the binary code must be extracted. On Windows machines this can result in a long start time. If you useaudible-clioften, I would prefer thedirectorypackage for Windows!Creating executables on your ownYou can create them yourself this waygitclonehttps://github.com/mkb79/audible-cli.gitcdaudible-cli
pipinstall.[pyi]# onefile outputpyinstaller--clean-F--hidden-importaudible_cli-naudible-cpyi_entrypoint# onedir outputpyinstaller--clean-D--hidden-importaudible_cli-naudible-cpyi_entrypointHintsThere are some limitations when using plugins. The binary maybe does not contain
all the dependencies from your plugin script.Tab CompletionTab completion can be provided for commands, options and choice values. Bash,
Zsh and Fish are supported. More information can be foundhere.Basic informationApp diraudible-cli use an app dir where it expects all necessary files.If theAUDIBLE_CONFIG_DIRenvironment variable is set, it uses the value
as config dir. Otherwise, it will use a folder depending on the operating
system.OSPathWindowsC:\Users\<user>\AppData\Local\audibleUnix~/.audibleMac OS X~/.audibleThe config fileThe config data will be stored in thetomlformat asconfig.toml.It has a main section namedAPPand sections for each profile created
namedprofile.<profile_name>profilesaudible-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 callaudible -P PROFILE_NAME, to select another profile.auth filesLike the config file, auth files are stored in the config dir too. If you
protected your auth file with a password callaudible -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 optionsAn option in the config file is separated by an underline. In the CLI prompt,
an option must be entered with a dash.APP sectionThe APP section supports the following options:primary_profile: The profile to use, if no other is specifiedfilename_mode: When using thedownloadcommand, 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 thefilename-modeoption of the
download command.Profile sectionauth_file: The auth file for this profilecountry_code: The marketplace for this profilefilename_mode: See APP section above. Will override the option in APP section.Getting startedUse theaudible-quickstartoraudible quickstartcommand in your shell
to create your first config, profile and auth file.audible-quickstartruns on the interactive mode, so you have to answer multiple questions to finish.If you have usedaudible quickstartand 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:add a new auth file using your second account usingaudible manage auth-file addadd a new profile to your config and use the second auth file usingaudible manage profile addCommandsCallaudible -hto 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-bytesapidownloadlibraryexportlistmanageauth-fileaddremoveconfigeditprofileaddlistremovequickstartwishlistexportlistaddremoveExample UsageTo download all of your audiobooks in the aaxc format use:audibledownload--all--aaxcTo download all of your audiobooks after the Date 2022-07-21 in aax format use:audibledownload--start-date"2022-07-21"--aax--allVerbosity optionThere are 6 different verbosity levels:debuginfowarningerrorcriticalBy default, the verbosity level is set toinfo. You can provide another level like so:audible -v <level> <subcommand> ....If you use thedownloadsubcommand with the--allflag there will be a huge output. Best practise is to set the verbosity level toerrorwithaudible -v error download --all ...PluginsPlugin FolderIf theAUDIBLE_PLUGIN_DIRenvironment variable is set, it uses the value
as location for the plugin dir. Otherwise, it will use a thepluginssubdir
of the app dir. Read above how Audible-cli searches the app dir.Custom CommandsYou can provide own subcommands and execute them withaudible SUBCOMMAND.
All plugin commands must be placed in the plugin folder. Every subcommand must
have his own file. Every file have to be namedcmd_{SUBCOMMAND}.py.
Each subcommand file must have a function calledclias 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 thePYTHONPATHvariable or
add this lines of code to the beginning of your command script:importsysimportpathlibsys.path.insert(0,str(pathlib.Path(__file__).parent))Examples can be foundhere.Own Plugin PackagesIf you want to develop a complete plugin package foraudible-cliyou 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.pyfromsetuptoolsimportsetupsetup(name="yourscript",version="0.1",py_modules=["yourscript"],install_requires=["click","audible_cli"],entry_points="""[audible.cli_plugins]cool_subcommand=yourscript.cli:cool_subcommandanother_subcommand=yourscript.cli:another_subcommand""",)Command priority orderCommands will be added in the following order:plugin dir commandsplugin packages commandsbuild-in commandsIf 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 foraudible-cliaudible-cli-flaskaudible-seriesIf you want to add information about your add-on please open a PR or a new issue!