Last active
March 11, 2025 16:28
-
-
Save Isengo1989/4778e1a5b4e2bf1b343b65dfeb110b70 to your computer and use it in GitHub Desktop.
Iterate through folders and convert your audiobooks from aax to m4b with ffmpeg to have a local backup or push audiobooks to audiobookshelf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ACTIVATION_KEY=xxxxxxxx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1. Get activation key with -> https://github.com/mkb79/audible-cli | |
# 2. Create .env with ACTIVATION_KEY=xxxxxxxx | |
# 3. Run with "bash m4b.sh" | |
# Folder strucutur should look like this | |
# Root -> Author -> Title -> *****.aax file | |
if [ -f .env ]; then | |
source .env | |
else | |
echo ".env file not found!" | |
exit 1 | |
fi | |
for author_dir in */; do | |
if [ -d "$author_dir" ]; then | |
for audiobook_dir in "$author_dir"*/; do | |
if [ -d "$audiobook_dir" ]; then | |
cd "$audiobook_dir" || continue | |
if ls *.aax 1> /dev/null 2>&1; then | |
ffmpeg -activation_bytes "$ACTIVATION_KEY" -i "$(ls *.aax | head -n 1)" -c copy -f segment -segment_time 3600 -reset_timestamps 1 part%d.m4b && rm "$(ls *.aax | head -n 1)" | |
fi | |
cd - || continue # Go back to the previous directory | |
fi | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment