YouTube Summarizer is a Flask web application that generates AI-powered summaries of YouTube videos and playlists. The app extracts transcripts from YouTube videos, creates concise summaries using multiple AI models (Google Gemini and OpenAI GPT models), and can convert summaries to audio using Google's Text-to-Speech API.
- Features
- Login Authentication (Optional)
- Prerequisites
- Usage with Docker
- Usage without Docker
- How to Use
- Project Structure
- API Requirements
- Troubleshooting
- Testing
- Contributing
- Changelog
- πΉ Video Summarization - Generate AI-powered summaries for individual YouTube videos
- π Playlist Support - Process and summarize entire YouTube playlists
- π€ Multi-Model AI Support - Choose from Google Gemini and OpenAI GPT models for summarization
- π Audio Generation - Convert summaries to MP3 audio files using Text-to-Speech
- πΎ Smart Caching - Store summaries and audio files to minimize API calls
- π¨ Clean Interface - Simple, responsive web UI for easy interaction
- β‘ Batch Processing - Handle multiple videos or playlists simultaneously
- π Optional Authentication - Secure your application with passcode-based login
YouTube Summarizer includes an optional login system to secure access to your application. This is particularly useful when deploying the application publicly or sharing it with a limited group of users.
- Simple passcode authentication - Single user access with a configurable passcode
- Brute force protection - Automatic IP-based lockout after failed attempts
- Session management - Secure session handling with configurable session keys
- Rate limiting - Configurable maximum attempts and lockout duration
Configure login functionality using these environment variables:
LOGIN_ENABLED=true # Enable/disable login (default: false)
LOGIN_CODE=your_secret_passcode # The passcode users must enter
SESSION_SECRET_KEY=your_random_key # Secret key for session encryption
MAX_LOGIN_ATTEMPTS=5 # Failed attempts before lockout (default: 5)
LOCKOUT_DURATION=15 # Lockout time in minutes (default: 15)
FLASK_DEBUG=false # Enable Flask debug mode (default: true, set false for production)Docker Compose - Add to your .env file:
GOOGLE_API_KEY=your_google_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
LOGIN_ENABLED=true
LOGIN_CODE=MySecurePasscode123
SESSION_SECRET_KEY=a-long-random-string-for-session-encryption
MAX_LOGIN_ATTEMPTS=3
LOCKOUT_DURATION=30
FLASK_DEBUG=falseManual Setup - Export environment variables:
export LOGIN_ENABLED=true
export LOGIN_CODE="MySecurePasscode123"
export SESSION_SECRET_KEY="a-long-random-string-for-session-encryption"
export MAX_LOGIN_ATTEMPTS=3
export LOCKOUT_DURATION=30
export FLASK_DEBUG=falseWhen login is enabled:
- Users are redirected to
/loginwhen accessing the application - After successful authentication, users can access all features normally
- Failed login attempts are tracked per IP address
- After exceeding max attempts, users are temporarily locked out
- Sessions persist until logout or browser closure
- Use a strong passcode - Combine letters, numbers, and symbols
- Generate a random session key - Use a cryptographically secure random string
- Configure appropriate lockout settings - Balance security with user experience
- Use HTTPS in production - Encrypt all communication with SSL/TLS
- Regularly rotate credentials - Change passcode and session key periodically
During development and testing, authentication is automatically bypassed when the TESTING environment variable is set to true. This ensures all existing tests continue to work without modification.
YouTube Summarizer supports using webshare proxies for fetching YouTube transcripts. This can help bypass IP restrictions, rate limiting, or geographic blocks that may prevent transcript retrieval from certain server environments.
Configure webshare proxy support using these environment variables:
WEBSHARE_PROXY_ENABLED=true # Enable/disable proxy (default: false)
WEBSHARE_PROXY_HOST=proxy.webshare.io # Proxy server hostname
WEBSHARE_PROXY_PORT=8080 # Proxy server port
WEBSHARE_PROXY_USERNAME=your_username # Webshare proxy username
WEBSHARE_PROXY_PASSWORD=your_password # Webshare proxy passwordDocker Compose - Add to your .env file:
GOOGLE_API_KEY=your_google_api_key_here
WEBSHARE_PROXY_ENABLED=true
WEBSHARE_PROXY_HOST=proxy.webshare.io
WEBSHARE_PROXY_PORT=8080
WEBSHARE_PROXY_USERNAME=myusername
WEBSHARE_PROXY_PASSWORD=mypasswordManual Setup - Export environment variables:
export WEBSHARE_PROXY_ENABLED=true
export WEBSHARE_PROXY_HOST="proxy.webshare.io"
export WEBSHARE_PROXY_PORT="8080"
export WEBSHARE_PROXY_USERNAME="myusername"
export WEBSHARE_PROXY_PASSWORD="mypassword"Consider enabling proxy support when:
- Transcript fetching fails with "YouTube is temporarily blocking requests" errors
- Running the application on cloud servers (AWS EC2, Google Cloud, etc.)
- Experiencing rate limiting from YouTube's transcript API
- Working with videos that may have geographic restrictions
- Keep proxy credentials secure - Store them in environment variables, not in code
- Use reputable proxy providers - Choose trusted services like Webshare.io
- Monitor proxy usage - Track bandwidth and request costs
- Test thoroughly - Verify transcript fetching works both with and without proxies
If you experience issues with proxy configuration:
- Verify all proxy environment variables are set correctly
- Check proxy credentials with your webshare provider
- Ensure the proxy service is active and has available bandwidth
- Test without proxy first to isolate issues
- Check application logs for proxy-related error messages
- Google API Key (required) with access to:
- YouTube Data API v3
- Google Generative AI (Gemini)
- Google Cloud Text-to-Speech API
- OpenAI API Key (optional) for GPT models
git clone <repository-url>
cd youtube-summarizerCreate a .env file in the project root:
GOOGLE_API_KEY=your_google_api_key_here
OPENAI_API_KEY=your_openai_api_key_here # Optional, for GPT modelsRun the initialization script to create the proper directory structure:
./init_data.shThis creates the data directory with the correct file structure to avoid volume mounting issues.
docker-compose up -dThe application will be available at http://localhost:5001
docker-compose down- Summaries and audio files are persisted in the
./datadirectory on your host machine - The container automatically restarts if it crashes
- Logs can be viewed with:
docker-compose logs -f
git clone <repository-url>
cd youtube-summarizerpython3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtCreate a .env file or export the environment variables:
export GOOGLE_API_KEY=your_google_api_key_here
export OPENAI_API_KEY=your_openai_api_key_here # Optional, for GPT modelsOn Windows:
set GOOGLE_API_KEY=your_google_api_key_here
set OPENAI_API_KEY=your_openai_api_key_hereFor development:
python app.pyFor production (using Gunicorn):
gunicorn --bind 0.0.0.0:5001 app:appThe application will be available at http://localhost:5001
-
Open the Web Interface: Navigate to
http://localhost:5001in your browser -
Login (if enabled):
- If authentication is enabled, you'll be redirected to the login page
- Enter the configured passcode to access the application
- You'll be automatically redirected to the main interface
-
Enter YouTube URLs:
- Paste one or more YouTube video URLs
- Playlist URLs are also supported
- Multiple URLs can be entered on separate lines
-
Generate Summaries: Click the "Summarize" button to process the videos
-
View Results:
- Summaries appear below each video
- Cached summaries are displayed in the sidebar
- Click the speaker icon to generate and play audio
youtube-summarizer/
βββ app.py # Main Flask application
βββ templates/
β βββ index.html # Web interface
βββ audio_cache/ # Generated MP3 files
βββ summary_cache.json # Cached summaries
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker image configuration
βββ docker-compose.yml # Docker Compose configuration
βββ .dockerignore # Docker ignore patterns
This project supports multiple AI providers. You can use either or both:
- YouTube Data API v3 - For fetching video metadata and playlist information
- Generative AI API - For accessing Google's Gemini models
- Cloud Text-to-Speech API - For converting summaries to audio
To set up Google APIs:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the required APIs
- Create an API key and add it as
GOOGLE_API_KEYto your.envfile
- OpenAI API - For accessing GPT-4o, GPT-4 Turbo, and GPT-3.5 Turbo models
To set up OpenAI API:
- Go to OpenAI Platform
- Create an account and generate an API key
- Add it as
OPENAI_API_KEYto your.envfile
- Google Gemini 2.5 Flash - Fast and efficient (default)
- Google Gemini 2.5 Pro - More capable for complex content
- OpenAI GPT-5 - Most advanced AI model available
- OpenAI GPT-5 Mini - Faster GPT-5 variant
- OpenAI GPT-4o - Advanced multimodal capabilities
- OpenAI GPT-4o Mini - Fast and cost-effective
-
"GOOGLE_API_KEY environment variable is not set"
- Ensure your
.envfile exists and contains your API key - For Docker: Make sure the
.envfile is in the same directory asdocker-compose.yml
- Ensure your
-
"No transcripts are available for this video"
- The video doesn't have captions/transcripts available
- The video might be private or age-restricted
-
API Quota Errors
- Check your Google Cloud Console for API usage limits
- The app uses caching to minimize API calls
-
Port Already in Use
- Change the port in
docker-compose.ymlor when running the app - Example:
python app.py --port 5002
- Change the port in
-
Stuck on login page / Invalid passcode
- Verify
LOGIN_CODEenvironment variable is set correctly - Ensure
LOGIN_ENABLED=trueis set - Check for typos in the passcode (case-sensitive)
- Verify
-
"Too many failed attempts" / Account locked
- Wait for the lockout duration to expire (default: 15 minutes)
- Or restart the application to clear the lockout
- Reduce
MAX_LOGIN_ATTEMPTSor increaseLOCKOUT_DURATIONif needed
-
Session expires immediately
- Ensure
SESSION_SECRET_KEYis set and consistent - Check that cookies are enabled in your browser
- Verify the session key doesn't contain special characters that might cause issues
- Ensure
-
Login not working in tests
- Tests automatically bypass authentication when
TESTING=true - This is expected behavior - tests should always pass regardless of login settings
- Tests automatically bypass authentication when
The project includes comprehensive unit and integration tests.
./quick_test.sh
# or
make testpython run_tests.py
# or
make coveragetests/test_app.py- Flask endpoint teststests/test_transcript_and_summary.py- Transcript and summary generation teststests/test_cache.py- Cache functionality teststests/test_integration.py- End-to-end integration tests
./run_quality_checks.sh
# or
make quality./run_quality_checks.sh --fix
# or
make fixmake format # Check code formatting
make lint # Run linting (pylint, flake8)
make test # Run tests onlyUse the Makefile for convenient development commands:
make help # Show all available commands
make install # Install all dependencies
make run # Run Flask app locally
make clean # Clean up cache files- Black - Code formatting
- isort - Import sorting
- Flake8 - Style guide enforcement
- Pylint - Static code analysis
- Bandit - Security linting
- Coverage - Test coverage reports
Feel free to submit issues, fork the repository, and create pull requests for any improvements. Please ensure all tests pass before submitting a PR.