drductus/audible-processor

By drductus

Updated 2 months ago

A docker image that lets you convert Audible AAX files into chapterized MP3s

Image
Content Management System
Developer Tools

524

Audible Processor is a docker container to help you create and manage a personal backup of your audible library. It will convert your AAX files into DRM-free mp3 files broken into chapters. The container can be used to run a daemon to watch a folder and convert any files found/create in it into mp3s, or to convert a single AAX.

By default, it will read the meta data from the AAX file and nest the MP3s in folders as such: "<out_dir>///mp3s".

v1.0.0 of this container used https://audible-converter.ml/ to look up the activation bytes to decrypt the DRM. However, they recently added reCaptcha to their API so that it can no longer be used by bots (my bad, sorry!). As such, in v2.0.0 and up the watcher will pause until we locate the activation bytes ourselves. See the Authentication section below for more instructions.

Volumes for default command:

  • /axx - this is the volume where the aax files can be found
  • /mp3 - this is the volume where the mp3 files are stored after conversion

Watcher Daemon

Usage

A simple watcher that will convert one book at a time as they are found

docker run -v "${PWD}/aax:/aax" -v "${PWD}/mp3:/mp3" drductus/audible-processor

A watcher that will convert three books at a time from a subfolder of the mounted volume

docker run -v "${PWD}/audible:/audible" drductus/audible-processor watch -t 3 -o /audible/mp3 /audible/aax

Environment variables can be used for most of the command line arguments so that they're easier to updated with managed deploys.

-o/--out => OUTPUT_DIR
--author-dir => USE_AUTHOR_DIR
--title-dir => USE_TITLE_DIR
-b/--activation-bytes => ACTIVATION_BYTES
-t/--threads => THREADS
-i/--interval => INTERVAL
-v/--verbose => VERBOSITY

Advanced watcher options

docker run drductus/audible-processor watch --help

Authentication

The service now requires that we locate the activation bytes ourselves. We can do this in 3 ways.

1. Determine activation bytes manually and pass them to the service manually

Use a service like https://audible-converter.ml/ to determine the activation bytes for a single aax file, then pass those directly to the service using the -b argument for the watcher or the processor.

Your new docker command would look something like this:

docker run -v "${PWD}/aax:/aax" -v "${PWD}/mp3:/mp3" drductus/audible-processor watch -b <activationBytes> -o /mp3 /aax

You can use the following linux command to extract the Checksum from a file: dd bs=1 skip=653 count=20 if=/path/to/aax/file | od -vt x1 -A n. This will output hex pairs that you can type in to site above instead of uploading a whole file.

2. Determine activation bytes manually and cache them for the service to use

Use a service like in step 1, but instead of using the -b command, we can save the bytes to a file that the service can referenced. In your /mp3 volume folder, run the following command: echo '<bytes>' > .auth. The service will now find this file and use its contents moving forward.

3. Use the new auth command on a running container

The new auth command will log in to Audible using your credentials and retrieve the activation bytes directly. It will then cache them for the service to use. Once the watcher is running, use the following command to start the authentication process, replacing /mp3 with the output path your watcher is using:

docker exec -it <containerId> auth -o /mp3

Copy the very long URL that is output into the console and paste it into a browser. In the browser, log in to your audible account. You will probably need to log in twice, the second time with a captcha. You will be redirected to a "Sorry" page. Copy that URL from your browser, and paste it back into the console window running the docker command and hit enter.

This should create the file /mp3/.auth that will contain your activation bytes. The service will now be able to use those and move forward with decrypting everything.

One-time Processor

One-time auth

If you don't want to run the watcher, you will still need to make sure the service knows the proper activation bytes. Steps 1 and 2 above will work without complication. Step 3 will need some minor modifications to use run instead of exec. Use the following command then follow the remained of the instructions for Step 3.

docker run --rm -it -v "${PWD}/audible:/audible" drductus/audible-processor auth -o /audible/mp3

This will properly create the .auth file in your destination output folder, where the service will be able to see it.

Usage

Convert a list of files in audible/axx into mp3s

docker run --rm -v "${PWD}/audible:/audible" drductus/audible-processor process -o /audible/mp3 /audible/aax/*.aax

Override the author and book title directories when converting an AAX file

docker run --rm -v "${PWD}/audible:/audible" drductus/audible-processor process -a 'Dan Wells' -t 'Mr. Monster' -o /audible/mp3 '/audible/aax/mr monster book 2.aax'

Advanced watcher options

docker run --rm drductus/audible-processor process --help

Future Changes

Now that we have to run multiple commands for the authentication, I don't like that the only way to determine the output folder is by using a command line argument. As such, I'm planning on adding this additional functionality in the future:

  1. Ability to trigger auth handling directly from the processor for one-time executions.

Changelog

v3.0.1
  • Updating file watching system to use polling
  • Adding new --interval command to the watcher to changed the FS polling interval
  • This is less "optimized" but allows network shares to be monitored properly
  • Adding environment variables for most of the watcher arguments
v3.0.0
  • Updating docker image to use a more update-to-date ffmpeg image
  • Updating docker image to install python dependencies directly
  • Cuts over 150MB from compressed docker image, and 400MB from decompressed image
  • Fixes a bunch of security issues reported by Docker Scout on the image (from 45C 151H 219M to 13H 62M 54L)
v2.0.0
  • Added internal handling for activating bytes with no more dependencies on external services
  • Added the new auth command
v1.0.0
  • Initial version using external web-service for activation bytes

Docker Pull Command

docker pull drductus/audible-processor