#!/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 -u 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 ===" SORTED=$(beet ls -f '$path' 'genres:Game' 2>>"$LOG" | sort -u) 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 ==="