# YouTube Summarizer API & Web Application A comprehensive AI-powered API ecosystem and web application that automatically extracts, transcribes, and summarizes YouTube videos. Features enterprise-grade developer tools, SDKs, agent framework integrations, and autonomous operations. ## ๐Ÿš€ What's New: Advanced API Ecosystem ### Developer API Platform - **๐Ÿ”Œ MCP Server**: Model Context Protocol integration for AI development tools - **๐Ÿ“ฆ Native SDKs**: Python and JavaScript/TypeScript SDKs with full async support - **๐Ÿค– Agent Frameworks**: LangChain, CrewAI, and AutoGen integrations - **๐Ÿ”„ Webhooks**: Real-time event notifications with HMAC authentication - **๐Ÿค– Autonomous Operations**: Self-managing system with intelligent automation - **๐Ÿ”‘ API Authentication**: Enterprise-grade API key management and rate limiting - **๐Ÿ“Š OpenAPI 3.0**: Comprehensive API documentation and client generation ## ๐ŸŽฏ Features ### Core Features - **Dual Transcript Options** โœ… **NEW**: Choose between YouTube captions, AI Whisper transcription, or compare both - **YouTube Captions**: Fast extraction (~3s) with standard quality - **Whisper AI**: Premium quality (~0.3x video duration) with superior punctuation and technical terms - **Smart Comparison**: Side-by-side analysis with quality metrics and recommendations - **Processing Time Estimates**: Know exactly how long each option will take - **Quality Scoring**: Confidence levels and improvement analysis - **Video Transcript Extraction**: Automatically fetch transcripts from YouTube videos - **AI-Powered Summarization**: Generate concise summaries using multiple AI models - **Multi-Model Support**: Choose between OpenAI GPT, Anthropic Claude, or DeepSeek - **Key Points Extraction**: Identify and highlight main topics and insights - **Chapter Generation**: Automatically create timestamped chapters - **Export Options**: Save summaries as Markdown, PDF, HTML, JSON, or plain text โœ… - **Template System**: Customizable export templates with Jinja2 support โœ… - **Bulk Export**: Export multiple summaries as organized ZIP archives โœ… - **Caching System**: Reduce API calls with intelligent caching - **Rate Limiting**: Built-in protection against API overuse ### Authentication & Security โœ… - **User Registration & Login**: Secure email/password authentication with JWT tokens - **Email Verification**: Required email verification for new accounts - **Password Reset**: Secure password recovery via email - **Session Management**: JWT access tokens with refresh token rotation - **Protected Routes**: User-specific summaries and history - **API Key Management**: Generate and manage personal API keys - **Security Features**: bcrypt password hashing, token expiration, CORS protection ### Summary Management โœ… - **History Tracking**: View all your processed summaries with search and filtering - **Favorites**: Star important summaries for quick access - **Tags & Notes**: Organize summaries with custom tags and personal notes - **Sharing**: Generate shareable links for public summaries - **Bulk Operations**: Select and manage multiple summaries at once ### Batch Processing โœ… - **Multiple URL Processing**: Process up to 100 YouTube videos in a single batch - **File Upload Support**: Upload .txt or .csv files with YouTube URLs - **Sequential Processing**: Smart queue management to control API costs - **Real-time Progress**: WebSocket-powered live progress updates - **Individual Item Tracking**: See status, errors, and processing time per video - **Retry Failed Items**: Automatically retry videos that failed processing - **Batch Export**: Download all summaries as a organized ZIP archive - **Cost Tracking**: Monitor API usage costs in real-time ($0.0025/1k tokens) ### Real-time Updates (NEW) โœ… - **WebSocket Progress Tracking**: Live updates for all processing stages - **Granular Progress**: Detailed percentage and sub-task progress - **Time Estimation**: Intelligent time remaining based on historical data - **Connection Recovery**: Automatic reconnection with message queuing - **Job Cancellation**: Cancel any processing job with immediate termination - **Visual Progress UI**: Beautiful progress component with stage indicators - **Heartbeat Monitoring**: Connection health checks and status indicators - **Offline Recovery**: Queued updates delivered when reconnected ## ๐Ÿ—๏ธ Architecture ``` [Web Interface] โ†’ [Authentication Layer] โ†’ [FastAPI Backend] โ†“ โ†“ [User Management] โ† [JWT Auth] โ†’ [Dual Transcript Service] โ† [YouTube API] โ†“ โ†“ โ†“ [AI Service] โ† [Summary Generation] โ† [YouTube Captions] | [Whisper AI] โ†“ โ†“ โ†“ [Database] โ†’ [User Summaries] โ†’ [Quality Comparison] โ†’ [Export Service] ``` ### Enhanced Transcript Extraction (v5.1) โœ… - **9-Tier Fallback Chain**: Guaranteed transcript extraction with multiple methods - YouTube Transcript API (primary) - Auto-generated captions - Whisper AI transcription - PyTubeFix, YT-DLP, Playwright fallbacks - External tools and web services - **Audio Retention System**: Save audio files for re-transcription - MP3 format (192kbps) for storage efficiency - Metadata tracking (duration, quality, download date) - Re-transcription without re-downloading - **Dual Transcript Architecture**: - **TranscriptSelector Component**: Choose between YouTube captions, Whisper AI, or both - **DualTranscriptService**: Orchestrates parallel extraction and quality comparison - **WhisperTranscriptService**: High-quality AI transcription with chunking support - **Quality Comparison Engine**: Analyzes differences and provides recommendations - **Real-time Progress**: WebSocket updates for long-running Whisper jobs ## ๐Ÿš€ Quick Start ### Prerequisites - Python 3.11+ - YouTube API Key (optional but recommended) - At least one AI service API key (OpenAI, Anthropic, or DeepSeek) ### ๐ŸŽฏ Quick Testing (No Authentication Required) **For immediate testing and development, access the admin page directly:** ```bash # Start the services cd backend && python3 main.py # Backend on port 8000 cd frontend && npm run dev # Frontend on port 3002 # Visit admin page (no login required) open http://localhost:3002/admin ``` The admin page provides full YouTube Summarizer functionality without any authentication - perfect for testing, demos, and development! ### Installation 1. **Clone the repository** ```bash git clone https://eniasgit.zeabur.app/demo/youtube-summarizer.git cd youtube-summarizer ``` 2. **Set up virtual environment** ```bash python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate ``` 3. **Install dependencies** ```bash # Backend dependencies cd backend pip install -r requirements.txt # Frontend dependencies (if applicable) cd ../frontend npm install ``` 4. **Configure environment** ```bash cp .env.example .env # Edit .env with your API keys and configuration ``` 5. **Initialize database** ```bash cd backend python3 -m alembic upgrade head # Apply existing migrations ``` 6. **Run the application** ```bash # Backend API cd backend python3 main.py # Runs on http://localhost:8000 # Frontend (in a separate terminal) cd frontend npm run dev # Runs on http://localhost:3000 ``` ## ๐Ÿ“ Project Structure ``` youtube-summarizer/ โ”œโ”€โ”€ backend/ โ”‚ โ”œโ”€โ”€ api/ # API endpoints โ”‚ โ”‚ โ”œโ”€โ”€ auth.py # Authentication endpoints โ”‚ โ”‚ โ”œโ”€โ”€ pipeline.py # Pipeline management โ”‚ โ”‚ โ”œโ”€โ”€ export.py # Export functionality โ”‚ โ”‚ โ””โ”€โ”€ videos.py # Video operations โ”‚ โ”œโ”€โ”€ services/ # Business logic โ”‚ โ”‚ โ”œโ”€โ”€ auth_service.py # JWT authentication โ”‚ โ”‚ โ”œโ”€โ”€ email_service.py # Email notifications โ”‚ โ”‚ โ”œโ”€โ”€ youtube_service.py # YouTube integration โ”‚ โ”‚ โ””โ”€โ”€ ai_service.py # AI summarization โ”‚ โ”œโ”€โ”€ models/ # Database models โ”‚ โ”‚ โ”œโ”€โ”€ user.py # User & auth models โ”‚ โ”‚ โ”œโ”€โ”€ summary.py # Summary models โ”‚ โ”‚ โ”œโ”€โ”€ batch_job.py # Batch processing models โ”‚ โ”‚ โ””โ”€โ”€ video.py # Video models โ”‚ โ”œโ”€โ”€ core/ # Core utilities โ”‚ โ”‚ โ”œโ”€โ”€ config.py # Configuration โ”‚ โ”‚ โ”œโ”€โ”€ database.py # Database setup โ”‚ โ”‚ โ””โ”€โ”€ exceptions.py # Custom exceptions โ”‚ โ”œโ”€โ”€ alembic/ # Database migrations โ”‚ โ”œโ”€โ”€ tests/ # Test suite โ”‚ โ”‚ โ”œโ”€โ”€ unit/ # Unit tests โ”‚ โ”‚ โ””โ”€โ”€ integration/ # Integration tests โ”‚ โ”œโ”€โ”€ main.py # Application entry point โ”‚ โ””โ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ frontend/ # React frontend โ”‚ โ”œโ”€โ”€ src/ # Source code โ”‚ โ”œโ”€โ”€ public/ # Static assets โ”‚ โ””โ”€โ”€ package.json # Node dependencies โ”œโ”€โ”€ docs/ # Documentation โ”‚ โ”œโ”€โ”€ stories/ # BMad story files โ”‚ โ””โ”€โ”€ architecture.md # System design โ””โ”€โ”€ README.md # This file ``` ## ๐Ÿ”ง Configuration ### Essential Environment Variables | Variable | Description | Required | |----------|-------------|----------| | **Authentication** | | | | `JWT_SECRET_KEY` | Secret key for JWT tokens | Yes | | `JWT_ALGORITHM` | JWT algorithm (default: HS256) | No | | `ACCESS_TOKEN_EXPIRE_MINUTES` | Access token expiry (default: 15) | No | | `REFRESH_TOKEN_EXPIRE_DAYS` | Refresh token expiry (default: 7) | No | | **Email Service** | | | | `SMTP_HOST` | SMTP server host | For production | | `SMTP_PORT` | SMTP server port | For production | | `SMTP_USER` | SMTP username | For production | | `SMTP_PASSWORD` | SMTP password | For production | | `SMTP_FROM_EMAIL` | Sender email address | For production | | **AI Services** | | | | `YOUTUBE_API_KEY` | YouTube Data API v3 key | Optional* | | `OPENAI_API_KEY` | OpenAI API key | One of these | | `ANTHROPIC_API_KEY` | Anthropic Claude API key | is required | | `DEEPSEEK_API_KEY` | DeepSeek API key | for AI | | **Database** | | | | `DATABASE_URL` | Database connection string | Yes | | **Application** | | | | `SECRET_KEY` | Application secret key | Yes | | `ENVIRONMENT` | dev/staging/production | Yes | | `APP_NAME` | Application name (default: YouTube Summarizer) | No | *YouTube API key improves metadata fetching but transcript extraction works without it. ## ๐Ÿงช Testing Run the test suite: ```bash cd backend # Run all tests python3 -m pytest tests/ -v # Run unit tests only python3 -m pytest tests/unit/ -v # Run integration tests python3 -m pytest tests/integration/ -v # With coverage report python3 -m pytest tests/ --cov=backend --cov-report=html ``` ## ๐Ÿ“ API Documentation Once running, visit: - Interactive API docs: `http://localhost:8000/docs` - Alternative docs: `http://localhost:8000/redoc` ### Authentication Endpoints - `POST /api/auth/register` - Register a new user - `POST /api/auth/login` - Login and receive JWT tokens - `POST /api/auth/refresh` - Refresh access token - `POST /api/auth/logout` - Logout and revoke tokens - `GET /api/auth/me` - Get current user info - `POST /api/auth/verify-email` - Verify email address - `POST /api/auth/reset-password` - Request password reset - `POST /api/auth/reset-password/confirm` - Confirm password reset ### Core Endpoints - `POST /api/pipeline/process` - Submit a YouTube URL for summarization - `GET /api/pipeline/status/{job_id}` - Get processing status - `GET /api/pipeline/result/{job_id}` - Retrieve summary result - `GET /api/summaries` - List user's summaries (requires auth) - `POST /api/export/{id}` - Export summary in different formats - `POST /api/export/bulk` - Export multiple summaries as ZIP ### Batch Processing Endpoints - `POST /api/batch/create` - Create new batch processing job - `GET /api/batch/{job_id}` - Get batch job status and progress - `GET /api/batch/` - List all batch jobs for user - `POST /api/batch/{job_id}/cancel` - Cancel running batch job - `POST /api/batch/{job_id}/retry` - Retry failed items in batch - `GET /api/batch/{job_id}/download` - Download batch results as ZIP - `DELETE /api/batch/{job_id}` - Delete batch job and results ## ๐Ÿ”ง Developer API Ecosystem ### ๐Ÿ”Œ MCP Server Integration The YouTube Summarizer includes a FastMCP server providing Model Context Protocol tools: ```python # Use with Claude Code or other MCP-compatible tools mcp_tools = [ "extract_transcript", # Extract video transcripts "generate_summary", # Create AI summaries "batch_process", # Process multiple videos "search_summaries", # Search processed content "analyze_video" # Deep video analysis ] # MCP Resources for monitoring mcp_resources = [ "yt-summarizer://video-metadata/{video_id}", "yt-summarizer://processing-queue", "yt-summarizer://analytics" ] ``` ### ๐Ÿ“ฆ Native SDKs #### Python SDK ```python from youtube_summarizer import YouTubeSummarizerClient async with YouTubeSummarizerClient(api_key="your-api-key") as client: # Extract transcript transcript = await client.extract_transcript("https://youtube.com/watch?v=...") # Generate summary summary = await client.generate_summary( video_url="https://youtube.com/watch?v=...", summary_type="comprehensive" ) # Batch processing batch = await client.batch_process(["url1", "url2", "url3"]) ``` #### JavaScript/TypeScript SDK ```typescript import { YouTubeSummarizerClient } from '@youtube-summarizer/sdk'; const client = new YouTubeSummarizerClient({ apiKey: 'your-api-key' }); // Extract transcript with progress tracking const transcript = await client.extractTranscript('https://youtube.com/watch?v=...', { onProgress: (progress) => console.log(`Progress: ${progress.percentage}%`) }); // Generate summary with streaming const summary = await client.generateSummary({ videoUrl: 'https://youtube.com/watch?v=...', stream: true, onChunk: (chunk) => process.stdout.write(chunk) }); ``` ### ๐Ÿค– Agent Framework Integration #### LangChain Tools ```python from backend.integrations.langchain_tools import get_youtube_langchain_tools from langchain.agents import create_react_agent tools = get_youtube_langchain_tools() agent = create_react_agent(llm=your_llm, tools=tools) result = await agent.invoke({ "input": "Summarize this YouTube video: https://youtube.com/watch?v=..." }) ``` #### Multi-Framework Support ```python from backend.integrations.agent_framework import create_youtube_agent_orchestrator orchestrator = create_youtube_agent_orchestrator() # Works with LangChain, CrewAI, AutoGen result = await orchestrator.process_video( "https://youtube.com/watch?v=...", framework=FrameworkType.LANGCHAIN ) ``` ### ๐Ÿ”„ Webhooks & Autonomous Operations #### Webhook Events ```javascript // Register webhook endpoint POST /api/autonomous/webhooks/my-app { "url": "https://myapp.com/webhooks", "events": [ "transcription.completed", "summarization.completed", "batch.completed", "error.occurred" ], "security_type": "hmac_sha256" } // Webhook payload example { "event": "transcription.completed", "timestamp": "2024-01-20T10:30:00Z", "data": { "video_id": "abc123", "transcript": "...", "quality_score": 0.92, "processing_time": 45.2 } } ``` #### Autonomous Rules ```python # Configure autonomous operations POST /api/autonomous/automation/rules { "name": "Auto-Process Queue", "trigger": "queue_based", "action": "batch_process", "parameters": { "queue_threshold": 10, "batch_size": 5 } } ``` ### ๐Ÿ”‘ API Authentication ```bash # Generate API key POST /api/auth/api-keys Authorization: Bearer {jwt-token} # Use API key in requests curl -H "X-API-Key: your-api-key" \ https://api.yoursummarizer.com/v1/extract ``` ### ๐Ÿ“Š Rate Limiting - **Free Tier**: 100 requests/hour, 1000 requests/day - **Pro Tier**: 1000 requests/hour, 10000 requests/day - **Enterprise**: Unlimited with custom limits ### ๐ŸŒ API Endpoints #### Developer API v1 - `POST /api/v1/extract` - Extract transcript with options - `POST /api/v1/summarize` - Generate summary - `POST /api/v1/batch` - Batch processing - `GET /api/v1/status/{job_id}` - Check job status - `POST /api/v1/search` - Search processed content - `POST /api/v1/analyze` - Deep video analysis - `GET /api/v1/webhooks` - Manage webhooks - `POST /api/v1/automation` - Configure automation ## ๐Ÿšข Deployment ### Docker ```bash docker build -t youtube-summarizer . docker run -p 8082:8082 --env-file .env youtube-summarizer ``` ### Production Considerations 1. **Database**: Use PostgreSQL instead of SQLite for production 2. **Security**: - Configure proper CORS settings - Set up SSL/TLS certificates - Use strong JWT secret keys - Enable HTTPS-only cookies 3. **Email Service**: Configure production SMTP server (SendGrid, AWS SES, etc.) 4. **Rate Limiting**: Configure per-user rate limits 5. **Monitoring**: - Set up application monitoring (Sentry, New Relic) - Configure structured logging - Monitor JWT token usage 6. **Scaling**: - Use Redis for session storage and caching - Implement horizontal scaling with load balancer - Use CDN for static assets ## ๐Ÿค Contributing 1. Fork the repository 2. Create a feature branch 3. Commit your changes 4. Push to the branch 5. Create a Pull Request ## ๐Ÿ“„ License This project is part of the Personal AI Assistant ecosystem. ## ๐Ÿ”— Related Projects - [Personal AI Assistant](https://eniasgit.zeabur.app/demo/my-ai-projects) - [YouTube Automation Service](https://eniasgit.zeabur.app/demo/youtube-automation) - [PDF Translator](https://eniasgit.zeabur.app/demo/pdf-translator) ## ๐Ÿ“ž Support For issues and questions, please create an issue in the repository.