#!/usr/bin/env bash
# scripts/manual/audio-clip-fetch.sh
#
# Manual: fetch and play recent server-side audio clips during field debugging.
# Not part of CI; requires SSH access to the target server.
set -euo pipefail

PI_HOST="nikto@192.168.42.253"   # adjust
REMOTE_DIR="/tmp"
TMPDIR="$(mktemp -d)"
trap 'rm -rf "$TMPDIR"' EXIT

scp -q "${PI_HOST}:${REMOTE_DIR}/ear-*.aac" "$TMPDIR/" 2>/dev/null \
  || { echo "❌ no clip files yet"; exit 1; }

LATEST=$(ls -1t "$TMPDIR"/ear-*.aac | head -n1)
echo "🎧 playing ${LATEST} ..."
gst-play-1.0 --quiet "${LATEST}"
