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.
This is meant to be an automated step between aquisition and tagging.
- Install via docker-compose
- Save new audiobooks to a /recentlyadded folder.
- All multifile m4b/mp3/m4a/ogg books will be converted to a chapterized m4b and saved to an /untagged folder
- This script will watch
/temp/recentlyadded
and automatically move mp3 books to/temp/merge
, then automatically put all m4b's in the output folder/temp/untagged
. It also makes a backup incase something goes wrong (can be disabled if desired).
Use the beets.io audible plugin to finish the tagging and sorting.
- The chapters are based on the mp3 tracks. A single mp3 file will become a single m4b with 1 chapter, also if the mp3 filenames are garbarge then your m4b chapternames will be terrible as well. See section on Chapters below for how to manually adjust.
- The conversion process actually strips some tags and covers from the files, which is why you need to use a tagger (mp3tag or beets.io) before adding to Plex.
Change the image to spencermksmith/auto-m4b
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:
cp -r "%F" "path/to/temp/recentlyadded"
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
│ ...
- Create a
temp
folder and keep the location in mind for Step 6 - Install docker https://docs.docker.com/engine/install/ubuntu/
- Manage docker as non-root https://docs.docker.com/engine/install/linux-postinstall/
- Install docker-compose https://docs.docker.com/compose/install/
- Create the compose file:
nano docker-compose.yml
- Paste the yaml code below into the compose file, and change the volume mount locations
- Put a test mp3 in the /temp/recentlyadded directory.
- 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
- Replace the
/path/to/...
with your actual folder locations, but leave the:
and everything after: - Replace the PUID and PGID with your user ( ? )
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
- Put a folder with mp3's in the
/temp/recentlyadded
and let the script process the book like normal - In the output folder (
/temp/untagged
) there will be a book folder that includes the recently converted *.m4b and a *.chapters.txt file. - Open the chapters file and edit/add/rename, then save
- Move the book folder (which contains the m4b and chapters.txt files) to
/temp/merge
- When the script runs it will re-chapterize the m4b and move it back to
/temp/untagged
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.
docker exec -it auto-m4b sh -c 'vi auto-m4b-tool.sh'
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.
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 m4b-tool options https://github.com/sandreas/m4b-tool#reference