#!/usr/bin/env bash
# scripts/clean.sh — audit which .webm sources in playlist/ already have a
# converted .m4a sibling (produced by scripts/convert.sh). Read-only; deletes
# nothing. Run from anywhere — operates on $OBS_DIR/playlist/.
set -euo pipefail

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OBS_DIR="$(cd "$DIR/.." && pwd)"
PLAYLIST="$OBS_DIR/playlist"

[[ -d "$PLAYLIST" ]] || { echo "  ✗ $PLAYLIST does not exist" >&2; exit 1; }
cd "$PLAYLIST"

shopt -s nullglob
for f in *.webm; do
  m="${f%.webm}.m4a"
  [[ -f "$m" ]] && echo "OK    $f → $m" || echo "MISS  $f (no m4a yet, keep!)"
done
