41ef26a40b
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>
36 lines
1.0 KiB
Bash
Executable File
36 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# gen-vgm-playlist.sh — regenerate vgm.m3u8 from all tracks tagged with
|
|
# genre "Game Soundtrack" in the beets library.
|
|
#
|
|
# Navidrome picks this up as a regular playlist. Safe to run manually anytime.
|
|
|
|
set -euo pipefail
|
|
|
|
PLAYLIST_DIR=${MUSIC_DATA_DIR:-/data/music}/playlists
|
|
OUT="${PLAYLIST_DIR}/vgm.m3u8"
|
|
LOG_DIR=${ALEMBIC_CONFIG_DIR:-/config}/logs
|
|
LOG="${LOG_DIR}/vgm-$(date +%Y%m%d).log"
|
|
|
|
mkdir -p "$LOG_DIR" "$PLAYLIST_DIR"
|
|
|
|
log() { echo "[$(date -Iseconds)] $*" | tee -a "$LOG"; }
|
|
|
|
log "=== Regenerating vgm.m3u8 ==="
|
|
|
|
# `|| true`: an empty or failed query just means no tracks, handled below as a
|
|
# warning. This is a cosmetic playlist regen, not worth aborting the job over.
|
|
SORTED=$(beet ls -f '$path' 'genres:Game' 2>>"$LOG" | sort -u || true)
|
|
COUNT=$(echo -n "$SORTED" | grep -c '^' || true)
|
|
|
|
if [[ "$COUNT" -gt 0 ]]; then
|
|
{
|
|
echo "#EXTM3U"
|
|
echo "$SORTED"
|
|
} > "$OUT"
|
|
log "vgm.m3u8 updated with $COUNT tracks"
|
|
else
|
|
log "WARNING: no tracks found — vgm.m3u8 not updated"
|
|
fi
|
|
|
|
log "=== Finished ==="
|