# 🔄 YouTube Metadata Extractor - Windows Update Script # This script updates the project on a Windows Server Write-Host "🔄 Updating YouTube Metadata Extractor on Windows..." -ForegroundColor Green # Configuration $ProjectDir = "$env:USERPROFILE\YouTube" # Function to print colored output function Write-Status { param($Message) Write-Host "✅ $Message" -ForegroundColor Green } function Write-Warning { param($Message) Write-Host "⚠️ $Message" -ForegroundColor Yellow } function Write-Error { param($Message) Write-Host "❌ $Message" -ForegroundColor Red } # Check if project directory exists if (!(Test-Path $ProjectDir)) { Write-Error "Project directory not found: $ProjectDir" Write-Error "Please run deploy.ps1 first to set up the project" exit 1 } Set-Location $ProjectDir # Stop services Write-Status "Stopping Windows Services..." try { Stop-Service "YouTube-API" -Force -ErrorAction SilentlyContinue Stop-Service "YouTube-Bot" -Force -ErrorAction SilentlyContinue Start-Sleep 3 } catch { Write-Warning "Could not stop services (they may not be running)" } # Pull latest changes Write-Status "Pulling latest changes from repository..." git pull origin main # Activate virtual environment and update dependencies Write-Status "Updating Python dependencies..." & "$ProjectDir\.venv\Scripts\Activate.ps1" python -m pip install --upgrade pip pip install -r requirements.txt pip install -r telegram_requirements.txt # Start services Write-Status "Starting Windows Services..." try { Start-Service "YouTube-API" Start-Sleep 5 Start-Service "YouTube-Bot" } catch { Write-Error "Could not start services. They may need to be created first." Write-Error "Please run deploy.ps1 to set up services." } # Check service status Write-Status "Checking service status..." Start-Sleep 5 try { $apiStatus = Get-Service "YouTube-API" -ErrorAction SilentlyContinue $botStatus = Get-Service "YouTube-Bot" -ErrorAction SilentlyContinue if ($apiStatus -and $apiStatus.Status -eq "Running") { Write-Status "YouTube API Server is running" } else { Write-Error "YouTube API Server is not running" if ($apiStatus) { Get-Service "YouTube-API" | Format-Table } } if ($botStatus -and $botStatus.Status -eq "Running") { Write-Status "YouTube Telegram Bot is running" } else { Write-Error "YouTube Telegram Bot is not running" if ($botStatus) { Get-Service "YouTube-Bot" | Format-Table } } } catch { Write-Error "Could not check service status. Services may not be installed." } Write-Status "Update completed!" Write-Host "" Write-Host "📋 Useful commands:" -ForegroundColor Cyan Write-Host "- Check service status: Get-Service YouTube-API, YouTube-Bot" Write-Host "- Start services: Start-Service YouTube-API, YouTube-Bot" Write-Host "- Stop services: Stop-Service YouTube-API, YouTube-Bot" Write-Host "- Restart services: Restart-Service YouTube-API, YouTube-Bot" Write-Host "- Check logs: Get-EventLog -LogName Application -Source YouTube*" Write-Host "- Manual start API: cd '$ProjectDir'; .\.venv\Scripts\Activate.ps1; python main.py" Write-Host "- Manual start Bot: cd '$ProjectDir'; .\.venv\Scripts\Activate.ps1; python run_telegram_bot.py"