@echo off
title YouTube Channel Archiver - Windows Build Script
echo ================================================================
echo YouTube Channel Archiver - Windows Build Script
echo ================================================================
echo.

echo [1/5] Checking Python installation...
python --version > nul 2>&1
if errorlevel 1 (
    echo ERROR: Python is not installed or not in PATH
    echo Please install Python from https://python.org
    pause
    exit /b 1
)
python --version

echo.
echo [2/5] Installing/updating build dependencies...
python -m pip install --upgrade pip
python -m pip install pyinstaller

echo.
echo [3/5] Creating executable with PyInstaller...
pyinstaller --onefile --windowed --name "YouTubeChannelArchiver" --distpath dist --workpath build youtube_archiver_standalone.py

echo.
echo [4/5] Testing the executable...
if exist "dist\YouTubeChannelArchiver.exe" (
    echo SUCCESS: Executable created at dist\YouTubeChannelArchiver.exe
) else (
    echo ERROR: Executable was not created
    pause
    exit /b 1
)

echo.
echo [5/5] Creating portable package...
if not exist "portable" mkdir portable
copy "dist\YouTubeChannelArchiver.exe" "portable\"
echo Portable version created in 'portable' folder

echo.
echo ================================================================
echo BUILD COMPLETED SUCCESSFULLY!
echo ================================================================
echo.
echo Files created:
echo - dist\YouTubeChannelArchiver.exe (main executable)
echo - portable\YouTubeChannelArchiver.exe (portable version)
echo.
echo You can now:
echo 1. Test the executable by running it
echo 2. Distribute the portable folder
echo 3. Create an installer using the Inno Setup script below
echo.
pause
