#!/usr/bin/env bash
set -euo pipefail
FEEDER_DIR="$HOME/ForensicLocalFeeder"
FEEDER_URL="http://13.140.158.51/local-feeder/source"
echo "Installing Forensic Local Feeder..."
mkdir -p "$FEEDER_DIR"
cd "$FEEDER_DIR"

if ! command -v python3 >/dev/null 2>&1; then
  echo "Python 3 is required. Install Python 3 from https://www.python.org/downloads/ and run this installer again."
  read -r -p "Press Enter to close."
  exit 1
fi

curl -fsSL "$FEEDER_URL" -o local_feeder_server.py
python3 -m yt_dlp --version >/dev/null 2>&1 || python3 -m pip install --user yt-dlp

echo
echo "Forensic Local Feeder is starting."
echo "Keep this window open while using local-assisted downloads."
echo "Then return to the analyzer page and click: Ask this computer to feed it."
python3 local_feeder_server.py
