@echo off
setlocal EnableExtensions

title Updating yt-dlp

set "YTD_DIR=C:\YTD"
set "YTDLP=%YTD_DIR%\yt-dlp.exe"
set "SILENT=0"

if /I "%~1"=="/silent" set "SILENT=1"

echo.
echo Checking for a yt-dlp update...
echo.

if not exist "%YTDLP%" (
    echo yt-dlp.exe was not found at:
    echo "%YTDLP%"
    echo.
    echo Run RunMe1st.bat before using this updater.
    echo.
    if "%SILENT%"=="0" pause
    exit /b 1
)

"%YTDLP%" -U

if errorlevel 1 (
    echo.
    echo The update did not complete successfully.
    echo Check your internet connection and antivirus protection.
    echo.
    if "%SILENT%"=="0" pause
    exit /b 1
)

echo.
echo yt-dlp is up to date.
echo.

if "%SILENT%"=="0" pause
exit /b 0
