3.7 KiB
3.7 KiB
Beautify Audio
One-file CLI to make tracks library-ready: convert to 320 kbps MP3, wipe old tags, retag via OneTagger Auto Tag, and rename to Artist - Title.mp3 with collision safety.
What it does:
- Converts any ffmpeg-readable source to 44.1 kHz stereo 320 kbps CBR MP3 (optional loudness normalization, default -11.5 LUFS).
- Strips existing metadata before retagging.
- Runs OneTagger Auto Tag with
onetagger-autotagger.json(Discogs/Spotify creds can be injected). - Renames the result using tagged artist/title; appends
-1,-2, etc. to avoid overwrites.
Quick start
- Install Python deps:
pip install -r requirements.txt - Install
ffmpegand ensure it is on PATH. - Install OneTagger CLI (≥1.7). On macOS, build from source and place the resulting
onetagger-clion PATH or next to this script. https://github.com/OneTagger/OneTagger - Run:
python beautify-audio.py /path/to/track.wav
Requirements
- Python 3.9+.
ffmpegon PATH.- Python deps from
requirements.txt(currentlymutagen). - OneTagger CLI on PATH or placed next to the script as
onetagger-cli(not bundled here because it is GPL-licensed). The Auto Tag profile is provided asonetagger-autotagger.json. - The helper module
onetagger_integration.pymust remain in the repo root (the script prepends the parent dir toPYTHONPATH).
Usage
python beautify-audio.py /path/to/track.wav
Useful flags:
--output-dir DIR– where to place the processed MP3 (default: source folder).--lufs -9.5– change loudness target; use--no-loudnessto disable normalization.--artist/--title/--album– seed metadata hints for tagging/renaming.--onetagger-cli /path/to/onetagger-cli– override CLI path (otherwise tries script folder or PATH).--skip-onetagger– only convert/strip/rename, skip tagging.- Auth:
--discogs-token,--spotify-id,--spotify-secret, or--auth-file auth.json.
Authentication resolution
Order of precedence:
- CLI flags
--auth-fileJSON withdiscogs_token,spotify_id,spotify_secret- Environment variables
DISCOGS_TOKEN,SPOTIFY_CLIENT_ID,SPOTIFY_CLIENT_SECRET auth.jsonnext to the script (if present)
Missing Spotify/Discogs creds cause those platforms to be dropped from the config copy for that run.
Workflow
- Pick output path with collision-safe suffixing.
- Convert source to MP3 (optional loudness normalization).
- Strip all metadata (skipped if
mutagenis missing). - Optionally rename for better OneTagger filename hints.
- Run OneTagger Auto Tag.
- Rename final file to a sanitized
Artist - Title.mp3.
Example (with credentials file)
python beautify-audio.py ~/Downloads/Track.wav \
--output-dir ~/Music/Prep \
--lufs -12 \
--auth-file ~/secrets/onetagger-auth.json
Example for Automator Script (Quick Action)
set -euo pipefail
# Where the repo lives
SCRIPT_ROOT="/path/to/beautify-audio"
PY_SCRIPT="$SCRIPT_ROOT/beautify-audio.py"
# Make sure Homebrew binaries are visible (ffmpeg, etc.)
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
LOG_DIR="$HOME/Library/Logs"
LOG_FILE="$LOG_DIR/beautify-audio-$(date +%Y%m%d-%H%M%S).log"
mkdir -p "$LOG_DIR"
# Make sure a virtual environment with the requirements installed is available
source "$SCRIPT_ROOT/.venv/bin/activate"
{
echo "==== $(date) ===="
for src in "$@"; do
echo "Processing: $src"
/usr/bin/env python3 "$PY_SCRIPT" "$src"
done
} >>"$LOG_FILE" 2>&1
osascript -e "display notification \"Beautify Audio finished for $# file(s).\" with title \"Beautify Audio\""
Notes
- Automator-friendly: one input file in, one clean MP3 out.
- If OneTagger is missing or fails, conversion and cleanup still run; renaming uses best-effort metadata.