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