Harden gen-djmix, gen-vgm, strip-mb-tags, notify-telegram under set -euo pipefail (R1)
Adds strict mode to four maintenance scripts, with guards so expected non-zero exits (empty beet queries, a missing config, a curl timeout) log/skip instead of aborting: gen-djmix bails cleanly if djmix-albums.txt is absent and tolerates a bad single query; gen-vgm tolerates an empty query; strip-mb-tags quotes its path arg and best-efforts the trailing beet update; notify-telegram guards curl so a network error still reaches its explicit "send failed" branch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# Runs daily from cron. Safe to run manually anytime.
|
||||
|
||||
set -u
|
||||
set -euo pipefail
|
||||
|
||||
CONFIG=${ALEMBIC_CONFIG_DIR:-/config}/pipeline/djmix-albums.txt
|
||||
PLAYLIST_DIR=${MUSIC_DATA_DIR:-/data/music}/playlists
|
||||
@@ -24,6 +24,11 @@ log() { echo "[$(date -Iseconds)] $*" | tee -a "$LOG"; }
|
||||
|
||||
log "=== Regenerating djmix.m3u8 ==="
|
||||
|
||||
if [[ ! -f "$CONFIG" ]]; then
|
||||
log "no djmix-albums.txt at $CONFIG — nothing to generate"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TRACKS=$(mktemp)
|
||||
|
||||
while IFS= read -r query; do
|
||||
@@ -40,7 +45,8 @@ while IFS= read -r query; do
|
||||
_t="${_t%"${_t##*[![:space:]]}"}"
|
||||
[[ -n "$_t" ]] && _args+=("$_t")
|
||||
done
|
||||
beet ls -f '$path' "${_args[@]}" 2>>"$LOG" >> "$TRACKS"
|
||||
# `|| true`: a malformed single query shouldn't abort the whole regen.
|
||||
beet ls -f '$path' "${_args[@]}" 2>>"$LOG" >> "$TRACKS" || true
|
||||
done < "$CONFIG"
|
||||
|
||||
# Deduplicate and sort
|
||||
|
||||
Reference in New Issue
Block a user