File size: 4,428 Bytes
6bf65c9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
@echo off
REM π YouTube Metadata Extractor - Windows Deployment (Batch)
REM Simple deployment script for Windows
echo π Starting deployment of YouTube Metadata Extractor on Windows...
REM Check if running as Administrator
net session >nul 2>&1
if %errorLevel% == 0 (
echo β
Running as Administrator
) else (
echo β This script must be run as Administrator
echo Please right-click this file and select "Run as administrator"
pause
exit /b 1
)
REM Set configuration
set PROJECT_DIR=%USERPROFILE%\YouTube
set REPO_URL=https://huggingface.co/spaces/dzianisBY/YouTube_Creator_MetaData
echo β
Installing Chocolatey (if not present)...
where choco >nul 2>&1
if %errorLevel% == 0 (
echo Chocolatey already installed
) else (
powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"
call refreshenv
)
echo β
Installing Python and Git...
choco install python git -y
call refreshenv
echo β
Creating project directory...
if not exist "%PROJECT_DIR%" mkdir "%PROJECT_DIR%"
cd /d "%PROJECT_DIR%"
echo β
Cloning repository...
if exist ".git" (
git pull origin main
) else (
git clone %REPO_URL% .
)
echo β
Setting up Python virtual environment...
python -m venv .venv
call .venv\Scripts\activate.bat
echo β
Installing Python dependencies...
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r telegram_requirements.txt
echo β
Creating .env template...
if not exist ".env" (
echo # YouTube API Configuration > .env
echo YOUTUBE_API_KEY=your_youtube_api_key_here >> .env
echo. >> .env
echo # Telegram Bot Configuration >> .env
echo TELEGRAM_TOKEN=your_telegram_bot_token_here >> .env
echo. >> .env
echo # MCP Server Configuration >> .env
echo MCP_BASE_URL=https://youtube-bot.tuttech.net/api/mcp >> .env
echo. >> .env
echo # Gemini AI Configuration >> .env
echo GEMINI_API_KEY=your_gemini_api_key_here >> .env
echo. >> .env
echo # Server Configuration >> .env
echo HOST=0.0.0.0 >> .env
echo PORT=8080 >> .env
echo β οΈ Created .env template file
echo β οΈ Please edit %PROJECT_DIR%\.env with your actual API keys!
)
echo β
Creating startup scripts...
echo @echo off > start-api.bat
echo cd /d "%PROJECT_DIR%" >> start-api.bat
echo call .venv\Scripts\activate.bat >> start-api.bat
echo python main.py >> start-api.bat
echo @echo off > start-bot.bat
echo cd /d "%PROJECT_DIR%" >> start-bot.bat
echo call .venv\Scripts\activate.bat >> start-bot.bat
echo python run_telegram_bot.py >> start-bot.bat
echo β
Installing NSSM for Windows Services...
choco install nssm -y
echo β
Creating Windows Services...
nssm remove "YouTube-API" confirm >nul 2>&1
nssm remove "YouTube-Bot" confirm >nul 2>&1
nssm install "YouTube-API" "%PROJECT_DIR%\start-api.bat"
nssm set "YouTube-API" DisplayName "YouTube MCP API Server"
nssm set "YouTube-API" Description "YouTube Metadata Extractor API Server"
nssm set "YouTube-API" Start SERVICE_AUTO_START
nssm install "YouTube-Bot" "%PROJECT_DIR%\start-bot.bat"
nssm set "YouTube-Bot" DisplayName "YouTube Telegram Bot"
nssm set "YouTube-Bot" Description "YouTube Metadata Extractor Telegram Bot"
nssm set "YouTube-Bot" Start SERVICE_AUTO_START
nssm set "YouTube-Bot" DependOnService "YouTube-API"
echo β
Starting services...
net start "YouTube-API"
timeout /t 5 /nobreak >nul
net start "YouTube-Bot"
echo β
Configuring Windows Firewall...
netsh advfirewall firewall add rule name="YouTube API Server" dir=in action=allow protocol=TCP localport=8080 >nul 2>&1
echo.
echo β
Deployment completed!
echo.
echo π Next steps:
echo 1. Edit %PROJECT_DIR%\.env with your API keys
echo 2. Restart services: net stop "YouTube-API" "YouTube-Bot" ^& net start "YouTube-API" "YouTube-Bot"
echo 3. Check services: sc query "YouTube-API" ^& sc query "YouTube-Bot"
echo.
echo π Service URLs:
echo - API Server: http://localhost:8080
echo - Health Check: http://localhost:8080/health
echo.
echo π± Service Management:
echo - Start: net start "YouTube-API" "YouTube-Bot"
echo - Stop: net stop "YouTube-API" "YouTube-Bot"
echo - Status: sc query "YouTube-API" ^& sc query "YouTube-Bot"
echo.
pause |