Skip to main content

m4b-merge

Status GitHub Issues GitHub Pull Requests License PyPI PyPI - Python Version Python package CodeFactor Grade PyPI - Downloads


A CLI tool which outputs consistently sorted, tagged, single m4b files regardless of the input.

📝 Table of Contents

🧐 About

m4b-merge was originally part of Bragi Books, but was split apart to allow savvy users to automate its usage in more advanced ways. Some of the things m4b-merge offers are:

  • Accepts single and multiple mp3, m4a and m4b files.
  • mp3s are converted to m4b. m4a/m4b files are edited/merged without conversion.
  • Matches existing bitrate and samplerate for target file conversions.
  • Final files moved to /output/Author/Book/Book: Subtitle.m4b format.
  • Moves finished files into done folder in input directory.

Metadata provided by audnexus:

  • Title, authors, narrators, description, series, genres, release year - written as tags.
  • Chapter times/titles (only when input is m4b or a single mp3) - written as tags and chapters.txt.
  • High resolution (2000x2000 or greater) cover art - embedded into output file.

🏁 Getting Started

Prerequisites

You can either install this project via pip directly or run it prepackaged in Docker:

  • If installing directly on your system, you'll need to install m4b-tool and it's dependants from the project's readme
  • If using Docker, all prerequisites are included in the image.

Installing

For a pip installation

Simply run

pip install m4b-merge

For a Docker installation

You'll need to specify input/output volumes in the run command for easy use later:

docker run --name=merge -v /path/to/input:/input -v /path/to/output:/output ghcr.io/djdembeck/m4b-merge:main

You may also specify the user and group to run as with env variables:

-e UID=99 -e GID=100

🔧 Running the tests

  • Run pip install pytest
  • To run all tests, run pytest from inside this project directory.
  • To run a single test, run pytest tests/test_NAME.py

🎈 Usage

Workflow

The process is simple

  1. Pass the file as input via -i FILE.ext or folder -i DIR/
  2. Enter the ASIN (found on audible.com) when prompted.
  3. Depending on necessary conversions, the process will take between 5 seconds and 5-10 minutes.

CLI usage

usage: m4b-merge [-h] [--api_url API_URL] [--completed_directory COMPLETED_DIRECTORY] -i INPUTS [INPUTS ...] [--log_level LOG_LEVEL]
                 [--num_cpus NUM_CPUS] [-o OUTPUT]

m4bmerge cli

optional arguments:
  -h, --help            show this help message and exit
  --api_url API_URL     Audnexus mirror to use
  --completed_directory COMPLETED_DIRECTORY
                        Directory path to move original input files to
  -i INPUTS [INPUTS ...], --inputs INPUTS [INPUTS ...]
                        Input paths to process
  --log_level LOG_LEVEL
                        Set logging level
  --num_cpus NUM_CPUS   Number of CPUs to use
  -o OUTPUT, --output OUTPUT
                        Output directory

When installed via pip, you can run inputs like so

m4b-merge -i /path/to/file.mp3

Or for multiple inputs

m4b-merge -i /path/to/file.mp3 /dir/ /path/to/other/file

On Docker, you can run inputs like so

docker run -it merge m4b-merge -i /input/file.mp3

For a folder of multiple audio files, simply pass the folder itself as an input, such as -i /input/dir

⛏️ Built Using

✍️ Authors

🎉 Acknowledgements

Release files for m4b-merge 0.4.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for m4b-merge 0.4.10
File Size Uploaded
m4b-merge-0.4.10.tar.gz 26.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for m4b-merge 0.4.10
File Interpreter ABI Platform
m4b_merge-0.4.10-py3-none-any.whl Python 3 none any Details

Total release size: 51.9 kB

Release files / m4b-merge-0.4.10.tar.gz

Download URL m4b-merge-0.4.10.tar.gz
Size 26.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0d5ec280e475726bb28a18be00cae0e72fafe9ef114c8ddb8c4b85cf87581c01
BLAKE2b-256 checksum
How to use checksums
883aa7f26a1cef8d863aaa6fb3e7b7166fc5621478c3b538eb01dd55b0476d91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release files / m4b_merge-0.4.10-py3-none-any.whl

Download URL m4b_merge-0.4.10-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccc9c6525792c8d3879f58d18a87fda1e491a0ac096ef327526163601f2d3aee
BLAKE2b-256 checksum
How to use checksums
5e77bb1eb7f0de0e8fecae742c8fa086aa158e38dd52327321984d6c1ca01c48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release history Release notifications | RSS feed

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.11

2 release files

This release

0.4.10 This release

2 release files

0.4.9

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page