https://github.com/aviz85/gemini-youtube-analyzer
๐ฅ YouTube Video Analyzer using Google Gemini AI with URL context support. Analyze any YouTube video with AI-powered insights.
https://github.com/aviz85/gemini-youtube-analyzer
ai api gemini-ai javascript nodejs vercel video-analysis youtube-analyzer
Last synced: about 2 months ago
JSON representation
๐ฅ YouTube Video Analyzer using Google Gemini AI with URL context support. Analyze any YouTube video with AI-powered insights.
- Host: GitHub
- URL: https://github.com/aviz85/gemini-youtube-analyzer
- Owner: aviz85
- Created: 2025-08-19T09:22:03.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-19T10:17:29.000Z (10 months ago)
- Last Synced: 2025-08-19T11:35:16.394Z (10 months ago)
- Topics: ai, api, gemini-ai, javascript, nodejs, vercel, video-analysis, youtube-analyzer
- Language: JavaScript
- Homepage: https://gemini-youtube-new.vercel.app
- Size: 56.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# YouTube Video Analyzer with Gemini AI
A powerful web application that analyzes YouTube videos using Google's Gemini AI with URL context support. Simply paste a YouTube URL and get detailed insights about the video content.
## โจ Features
- **YouTube Video Analysis**: Analyze any public YouTube video using Google's Gemini AI
- **URL Context Support**: Leverages Gemini's `urlContext` tool for direct video processing
- **Beautiful Web Interface**: Clean, responsive design with loading states and error handling
- **RESTful API**: Well-documented API endpoints for programmatic access
- **Comprehensive Testing**: Full test suite with 9 automated tests
- **Production Ready**: Deployed on Vercel with proper error handling and CORS support
## ๐ Live Demo
- **Web Interface**: [https://gemini-youtube-new.vercel.app](https://gemini-youtube-new.vercel.app)
- **API Endpoint**: `POST /api/analyze`
## ๐ ๏ธ Quick Start
### Prerequisites
- Node.js 18+
- Google Gemini API key ([Get one here](https://makersuite.google.com/app/apikey))
### Installation
1. **Clone the repository**
```bash
git clone https://github.com/aviz85/gemini-youtube-analyzer.git
cd gemini-youtube-analyzer
```
2. **Install dependencies**
```bash
npm install
```
3. **Set up environment variables**
```bash
echo "GEMINI_API_KEY=your_api_key_here" > .env
```
4. **Run locally**
```bash
# Option 1: Using Vercel dev
npm run vercel-dev
# Option 2: Simple Express server
node -e "
const express=require('express');
const app=express();
app.use(express.json(),express.static('.'));
app.all('/api/*',(req,res)=>require('./api/'+req.path.split('/')[2])(req,res));
app.listen(8080,()=>console.log('โ
Running: http://localhost:8080'));
"
```
5. **Run tests**
```bash
npm test
```
## ๐ API Usage
### Analyze Video
**Endpoint:** `POST /api/analyze`
**Request Body:**
```json
{
"youtubeUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"prompt": "What is this video about? Provide a detailed summary."
}
```
**Response:**
```json
{
"success": true,
"analysis": "This video is the official music video for Rick Astley's iconic song 'Never Gonna Give You Up.' It features Rick Astley singing and dancing in various locations..."
}
```
**Error Response:**
```json
{
"error": "Please provide a valid YouTube URL"
}
```
### Test Connection
**Endpoint:** `GET /api/analyze`
**Response:**
```json
{
"message": "YouTube Analyzer API is working",
"timestamp": "2025-08-19T08:52:36.715Z",
"endpoints": {
"POST /api/analyze": "Analyze YouTube video content"
}
}
```
## ๐ง Configuration
### Environment Variables
- `GEMINI_API_KEY` (required): Your Google Gemini API key
### Deployment
**Vercel (recommended):**
```bash
npm run deploy
```
**Other platforms:**
- The app works on any Node.js hosting platform
- API functions are in the `/api` directory
- Static files are served from the root
## ๐งช Testing
The project includes comprehensive tests covering:
- CORS handling
- Input validation
- YouTube URL format validation
- API error handling
- Streaming response aggregation
- Edge cases and error scenarios
```bash
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
```
## ๐ Project Structure
```
โโโ api/
โ โโโ analyze.js # Main YouTube analyzer endpoint
โ โโโ hello.js # Test endpoint
โโโ __tests__/
โ โโโ analyze.test.js # Comprehensive test suite
โโโ index.html # Beautiful web interface
โโโ vercel.json # Vercel deployment config
โโโ package.json # Dependencies and scripts
โโโ README.md # This file
```
## ๐ Security Features
- Input validation and sanitization
- CORS headers properly configured
- Environment variable protection
- Error message sanitization
- Rate limiting ready (can be easily added)
## ๐ค Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Run tests (`npm test`)
4. Commit changes (`git commit -m 'Add amazing feature'`)
5. Push to branch (`git push origin feature/amazing-feature`)
6. Open a Pull Request
## ๐ License
MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- Google Gemini AI for the powerful video analysis capabilities
- Vercel for seamless deployment platform
- The open-source community for inspiration and tools
## โก Performance
- Streaming responses for faster perceived performance
- Efficient error handling
- Minimal dependencies
- Optimized for both development and production
---
**Made with โค๏ธ by [aviz85](https://github.com/aviz85)**