2d7243332d
Move six scripts that are not wired into the app, scheduler, or web UI out of the active pipeline/lib into pipeline/lib/manual, so the scheduled scripts are easy to see and these stay available for hands-on use: convert-m4a.sh, fix-empty-album.sh, backfill-spotify-tags.sh, backfill-buy-url.py, recover-azuracast-playlists.py, import-dj-collection.py. Adds a README explaining each, and extends the Dockerfile chmod to cover the new folder. Nothing referenced these from active code (verified), so no wiring changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
58 lines
1.7 KiB
Bash
Executable File
58 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# Convert m4a files in-place: AAC -> MP3 (V0 VBR), ALAC -> FLAC (lossless).
|
|
# Preserves metadata + embedded cover art. Deletes original on success.
|
|
set -u
|
|
|
|
LOG=${ALEMBIC_CONFIG_DIR:-/config}/logs/convert-m4a-$(date +%Y%m%d-%H%M%S).log
|
|
mkdir -p "$(dirname "$LOG")"
|
|
|
|
log() { echo "[$(date -Iseconds)] $*" | tee -a "$LOG"; }
|
|
|
|
OK_AAC=0
|
|
OK_ALAC=0
|
|
FAIL=0
|
|
|
|
while IFS= read -r -d '' f; do
|
|
codec=$(ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of csv=p=0 "$f" 2>/dev/null | tr -d ',')
|
|
base="${f%.m4a}"
|
|
case "$codec" in
|
|
aac)
|
|
out="${base}.mp3"
|
|
if [[ -e "$out" ]]; then log "SKIP-EXISTS: $out"; FAIL=$((FAIL+1)); continue; fi
|
|
if ffmpeg -nostdin -hide_banner -loglevel error -i "$f" \
|
|
-map 0 -c:v copy -c:a libmp3lame -q:a 0 -id3v2_version 3 \
|
|
"$out" 2>>"$LOG"; then
|
|
rm -f "$f"
|
|
log "AAC→MP3: $out"
|
|
OK_AAC=$((OK_AAC+1))
|
|
else
|
|
log "FAIL-AAC: $f"
|
|
rm -f "$out" 2>/dev/null
|
|
FAIL=$((FAIL+1))
|
|
fi
|
|
;;
|
|
alac)
|
|
out="${base}.flac"
|
|
if [[ -e "$out" ]]; then log "SKIP-EXISTS: $out"; FAIL=$((FAIL+1)); continue; fi
|
|
if ffmpeg -nostdin -hide_banner -loglevel error -i "$f" \
|
|
-map 0 -c:v copy -c:a flac -compression_level 8 \
|
|
"$out" 2>>"$LOG"; then
|
|
rm -f "$f"
|
|
log "ALAC→FLAC: $out"
|
|
OK_ALAC=$((OK_ALAC+1))
|
|
else
|
|
log "FAIL-ALAC: $f"
|
|
rm -f "$out" 2>/dev/null
|
|
FAIL=$((FAIL+1))
|
|
fi
|
|
;;
|
|
*)
|
|
log "SKIP-OTHER ($codec): $f"
|
|
;;
|
|
esac
|
|
done < <(find ${MUSIC_DATA_DIR:-/data/music}/Library -type f -iname "*.m4a" -print0 2>/dev/null)
|
|
|
|
log ""
|
|
log "=== AAC→MP3: $OK_AAC | ALAC→FLAC: $OK_ALAC | Failed: $FAIL ==="
|
|
log "Log: $LOG"
|