Home

Awesome

Auto-M4B

Join the chat at https://gitter.im/Audiobook-Server/auto-m4b

This container is mostly based on the powerful m4b-tool made by sandreas
This repo is my fork of the fantastic docker-m4b-tool created by 9Mad-Max5.

This is a docker container that will watch a folder for new books, auto convert mp3 books to chapterized m4b, and move all m4b books to a specific output folder, this output folder is where the beets.io audible plugin will look for audiobooks and use the audible api to perfectly tag and organize your books.

Intended Use

This is meant to be an automated step between aquisition and tagging.

Use the beets.io audible plugin to finish the tagging and sorting.

Known Limitations

Need ARM Support?

Change the image to spencermksmith/auto-m4b

Using torrents and need to preserve seeding?

In the settings of your client add this line to Run external program on torrent completion, it will copy all finished torrent files to your "recentlyadded" folder:

How to use

This docker assumes the following folder structure:

temp
│
└───recentlyadded # Input folder Add new books here
│     │     book1.m4b
│     |     book2.mp3
|     └─────book3
│           │   01-book3.mp3
│           │   ... 
└───merge # folder the script uses to combine mp3's
│     └─────book2
│           │   01-book2.mp3
│           │   ...
└───untagged # Output folder where all m4b's wait to be tagged
│     └─────book4
│           │   book4.m4b
└───delete # needed by the script
|
└───fix # Manually fix books
|
└───backup # Backups incase anything goes wrong
      └─────book2
            │   01-book2.mp3
            │   ... 

Installation

  1. Create a temp folder and keep the location in mind for Step 6
  2. Install docker https://docs.docker.com/engine/install/ubuntu/
  3. Manage docker as non-root https://docs.docker.com/engine/install/linux-postinstall/
  4. Install docker-compose https://docs.docker.com/compose/install/
  5. Create the compose file:
    nano docker-compose.yml
  6. Paste the yaml code below into the compose file, and change the volume mount locations
  7. Put a test mp3 in the /temp/recentlyadded directory.
  8. Start the docker (It should convert the mp3 and leave it in your /temp/untagged directory. It runs automatically every 5 min)
    docker-compose up -d

Example docker-compose.yml

docker-compose.yml

version: '3.7'
services:
  auto-m4b:
    image: seanap/auto-m4b
    container_name: auto-m4b
    volumes:
      - /path/to/config:/config
      - /path/to/temp:/temp
    environment:
      - PUID=1000
      - PGID=1000
      - CPU_CORES=2
      - SLEEPTIME=1m
      - MAKE_BACKUP=Y

To Manually Set Chapters:

  1. Put a folder with mp3's in the /temp/recentlyadded and let the script process the book like normal
  2. In the output folder ( /temp/untagged ) there will be a book folder that includes the recently converted *.m4b and a *.chapters.txt file.
  3. Open the chapters file and edit/add/rename, then save
  4. Move the book folder (which contains the m4b and chapters.txt files) to /temp/merge
  5. When the script runs it will re-chapterize the m4b and move it back to /temp/untagged

Advanced Options

Edit the script that is run

You shouldn't need to change any options, but if you want to you will need to exec into the docker container. By default only vim text editor is installed, you will need to do a apt-get update && apt-get install nano if you want to use nano to edit the scipt.

CPU Cores

The script will automatically use all CPU cores available, to change the amount of cpu cores for the converting change the --jobs flag in the m4b-tool command, but do not set it higher than the amount of cores available.

Backup Folder

For those copying files from another source into the recentlyadded folder, it might not make sense to waste time copying to the backup folder (because they were already copied from somewhere else). Backing up is enabled by default. To disable this copy operation, change this line in your compose file: - MAKE_BACKUP=N.

More Reading

More m4b-tool options https://github.com/sandreas/m4b-tool#reference