# Playlist Monitor Service - Comprehensive Build Guide ## 📋 Table of Contents 1. [Prerequisites](#prerequisites) 2. [Build Options](#build-options) 3. [Development Setup](#development-setup) 4. [Production Build](#production-build) 5. [UI Integration Options](#ui-integration-options) 6. [Docker Build](#docker-build) 7. [Troubleshooting](#troubleshooting) 8. [Advanced Build Options](#advanced-build-options) ## 🔧 Prerequisites ### System Requirements - **Python**: 3.13+ (3.14 recommended) - **Operating System**: Linux/macOS/Windows WSL2 - **Memory**: Minimum 512MB RAM, 1GB recommended - **Storage**: 100MB for application + space for downloads - **Network**: Access to YouTube and MeTube instance ### Software Dependencies ```bash # Ubuntu/Debian sudo apt update sudo apt install python3.13 python3.13-dev python3.13-venv build-essential curl git # macOS (using Homebrew) brew install python@3.13 curl git # CentOS/RHEL/Fedora sudo dnf install python3.13 python3.13-devel gcc curl git ``` ### MeTube Requirements - MeTube instance running (locally or remotely) - MeTube version that supports playlist downloads - Network connectivity between services ## 🏗️ Build Options ### Option 1: Modern Python with uv (Recommended) **Fastest, most reliable method** ```bash # Install uv package manager curl -LsSf https://astral.sh/uv/install.sh | sh source ~/.cargo/env # Clone and setup cd /root/workspace/tubewatch/playlist-monitor uv sync # Run uv run python -m app.main ``` ### Option 2: Traditional pip/venv **Standard Python approach** ```bash # Create virtual environment python3.13 -m venv venv source venv/bin/activate # Linux/macOS # or venv\Scripts\activate # Windows # Install dependencies pip install --upgrade pip pip install -e . # Run python -m app.main ``` ### Option 3: Poetry (Alternative) **For Poetry users** ```bash # Install Poetry curl -sSL https://install.python-poetry.org | python3 - # Setup project poetry install poetry run python -m app.main ``` ## 🛠️ Development Setup ### 1. Environment Configuration ```bash # Copy environment template cp .env.example .env # Edit configuration nano .env ``` **Essential settings:** ```env # MeTube Integration METUBE_URL=http://localhost:8081 # Database DATABASE_URL=sqlite:///data/playlists.db # Server HOST=0.0.0.0 PORT=8082 # Scheduler DEFAULT_CHECK_INTERVAL=60 MAX_CONCURRENT_DOWNLOADS=3 # Logging LOG_LEVEL=INFO ``` ### 2. Development Dependencies ```bash # Install development dependencies uv sync --extra dev # Or with pip pip install -e ".[dev]" ``` ### 3. Development Tools Setup ```bash # Code formatting uv run black app/ tests/ uv run isort app/ tests/ # Type checking uv run mypy app/ # Linting uv run flake8 app/ tests/ ``` ### 4. Database Setup ```bash # Create data directory mkdir -p data logs # Initialize database (automatic on first run) uv run python -c "from app.core.database import engine, Base; Base.metadata.create_all(bind=engine)" ``` ## 🚀 Production Build ### Step 1: Production Dependencies ```bash # Install only production dependencies uv sync --no-dev # Or with pip pip install -r requirements.txt ``` ### Step 2: Production Configuration ```bash # Create production environment cp .env.example .env.production # Edit production settings nano .env.production ``` **Production recommendations:** ```env # Security DEBUG=false LOG_LEVEL=WARNING CORS_ORIGINS=["https://yourdomain.com"] # Performance MAX_CONCURRENT_DOWNLOADS=5 DEFAULT_CHECK_INTERVAL=30 # Database (PostgreSQL recommended) DATABASE_URL=postgresql://user:pass@localhost/metube_playlists ``` ### Step 3: Production Server ```bash # Use production ASGI server uv run gunicorn app.main:app \ --workers 4 \ --worker-class uvicorn.workers.UvicornWorker \ --bind 0.0.0.0:8082 \ --log-level info # Or with uvicorn directly uv run uvicorn app.main:app \ --host 0.0.0.0 \ --port 8082 \ --workers 4 \ --log-level info ``` ## 🎨 UI Integration Options ### Option 1: Standalone Web UI (Recommended) Create a separate frontend application that communicates with the API. **Technologies:** - **React** with TypeScript - **Vue.js 3** with Composition API - **SvelteKit** for modern approach **Example React setup:** ```bash # Create React app cd /root/workspace/tubewatch npx create-react-app playlist-monitor-ui --template typescript cd playlist-monitor-ui # Install UI libraries npm install @mui/material @emotion/react @emotion/styled axios react-query npm install @mui/icons-material @mui/x-data-grid date-fns # Start development npm start ``` ### Option 2: Extend MeTube Angular UI Modify the existing MeTube Angular frontend to include playlist monitoring. **Approach:** 1. Add new Angular components to MeTube's UI 2. Integrate with existing MeTube routing 3. Use MeTube's existing styling and components **Integration points:** - Add playlist tab to main navigation - Extend existing download interface - Reuse MeTube's component library ### Option 3: Simple HTML Dashboard For minimal UI requirements. ```bash # Create simple dashboard mkdir ui cd ui # Create index.html with vanilla JS cat > index.html << 'EOF'
${playlist.url}
Status: ${playlist.enabled ? 'Enabled' : 'Disabled'}