@echo off
setlocal
set FEEDER_DIR=%USERPROFILE%\ForensicLocalFeeder
set FEEDER_URL=http://13.140.158.51/local-feeder/source
mkdir "%FEEDER_DIR%" >nul 2>nul
cd /d "%FEEDER_DIR%"

where python >nul 2>nul
if errorlevel 1 (
  echo Python 3 is required.
  echo Attempting to install Python with winget...
  winget install --id Python.Python.3.12 -e --source winget
)

where python >nul 2>nul
if errorlevel 1 (
  echo Python is still not available. Install Python 3 from https://www.python.org/downloads/ and run this installer again.
  pause
  exit /b 1
)

powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -Uri '%FEEDER_URL%' -OutFile '%FEEDER_DIR%\local_feeder_server.py'"
python -m yt_dlp --version >nul 2>nul
if errorlevel 1 python -m pip install --user yt-dlp

echo.
echo Forensic Local Feeder is starting.
echo Keep this window open while using local-assisted downloads.
python local_feeder_server.py
pause
