Skip to content

gabubu-dev/youtube-content-analyzer

Repository files navigation

YouTube Content Analyzer

An AI-powered tool that analyzes YouTube videos for content patterns, hooks, themes, and engagement strategies. Perfect for content creators who want to understand what makes videos successful in their niche.

Features

  • Video Discovery: Search and find top-performing videos in any niche using YouTube Data API
  • Transcript Extraction: Automatically pulls full video transcripts
  • AI-Powered Analysis: Uses LLMs (OpenAI/Claude) to extract:
    • Opening hooks and attention grabbers
    • Key themes and topics
    • Content structure and flow
    • Engagement strategies
    • Storytelling techniques
  • Batch Processing: Analyze multiple videos at once
  • Export Results: Save analysis to JSON, CSV, or markdown reports

Installation

Prerequisites

  • Python 3.9 or higher
  • YouTube Data API key
  • OpenAI API key or Anthropic API key

Setup

  1. Clone the repository:
git clone https://github.com/gabubu-dev/youtube-content-analyzer.git
cd youtube-content-analyzer
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure API keys:
cp config.example.json config.json
# Edit config.json with your API keys

Configuration

Create a config.json file with your API credentials:

{
  "youtube_api_key": "your-youtube-api-key",
  "openai_api_key": "your-openai-api-key",
  "anthropic_api_key": "your-anthropic-api-key",
  "default_llm": "openai",
  "model": "gpt-4-turbo-preview",
  "max_videos": 10,
  "language": "en"
}

Usage

Command Line Interface

Analyze top videos in a niche:

python -m src.cli search "content creation tips" --max-results 5 --analyze

Analyze a specific video:

python -m src.cli analyze https://www.youtube.com/watch?v=VIDEO_ID

Batch analyze from a list:

python -m src.cli batch video_urls.txt --output results.json

Python API

from src.analyzer import YouTubeAnalyzer
from src.config import load_config

# Initialize
config = load_config("config.json")
analyzer = YouTubeAnalyzer(config)

# Search and analyze
results = analyzer.search_and_analyze("productivity tips", max_results=5)

# Analyze specific video
analysis = analyzer.analyze_video("https://www.youtube.com/watch?v=VIDEO_ID")

# Access analysis results
print(analysis.hooks)
print(analysis.themes)
print(analysis.engagement_strategies)

Architecture

src/
├── __init__.py
├── cli.py              # Command line interface
├── config.py           # Configuration management
├── youtube_client.py   # YouTube API wrapper
├── transcript.py       # Transcript extraction
├── llm_client.py       # LLM API clients (OpenAI/Claude)
├── analyzer.py         # Main analysis orchestration
├── prompts.py          # Analysis prompt templates
└── export.py           # Export functionality

tests/
├── test_youtube_client.py
├── test_transcript.py
├── test_analyzer.py
└── test_export.py

Development

Running Tests

pytest tests/

Code Style

This project follows PEP 8 style guidelines. Format code with:

black src/ tests/

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with clear commit messages
  4. Add tests for new functionality
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Acknowledgments

  • Built with YouTube Data API v3
  • Uses youtube-transcript-api for transcript extraction
  • Powered by OpenAI and Anthropic LLMs

About

AI agent that analyzes YouTube videos for content patterns, hooks, themes, and engagement strategies

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages