Skip to content
This repository was archived by the owner on Jan 18, 2026. It is now read-only.

namanxajmera/yt-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YouTube Monitor Bot

Python License

Intelligent YouTube channel monitoring with AI-powered summaries delivered via Telegram. Never miss important content from your favorite creators.

Features

  • Multi-Channel Monitoring - Track unlimited YouTube channels simultaneously using RSS feeds (no API quota limits)
  • AI-Powered Summaries - Automatic video summarization using Google's Gemini 2.0 Flash
  • Telegram Integration - Get notifications with relevance scores, key takeaways, and watch recommendations
  • Smart Retry Logic - Attempts to fetch transcripts for up to 48 hours for videos that don't have them immediately
  • Interest-Based Filtering - Customizable interest profile for personalized relevance scoring
  • Skip Shorts - Automatically filters out YouTube Shorts and videos under 5 minutes
  • Interactive Bot Commands - Manage channels, check health, and view status via Telegram
  • State Tracking - Tracks video processing status and retry attempts

How It Works

  1. Hourly Monitoring: Checks all configured YouTube channels for new videos via RSS feeds
  2. Transcript Fetching: Attempts to download video transcripts (retries every hour for up to 48 hours if unavailable)
  3. AI Analysis: Generates structured summaries using Gemini 2.0 with your interest profile
  4. Smart Notifications: Only sends Telegram notifications when summaries are successfully generated
  5. Interactive Management: Use Telegram bot commands to add/remove channels and check system health

Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/youtube-monitor-bot.git
    cd youtube-monitor-bot
  2. Install dependencies

    pip install -r requirements.txt
  3. Configure environment variables

    cp .env.example .env
    # Edit .env with your actual API keys
  4. Set up your interests (optional)

    Edit config/my_interests.txt to customize the AI's relevance scoring for your preferences.

  5. Add YouTube channels

    Edit config/channels.txt and add channels (one per line):

    @GregIsenberg
    https://www.youtube.com/@MyFirstMillionPod
    

Usage

Using the Wrapper Script (Recommended)

# Check for new videos
./monitor.sh check

# Start interactive Telegram bot
./monitor.sh bot

# Check system health
./monitor.sh health

# Test Telegram notifications
./monitor.sh test

Direct Python Commands

Run a one-time check for new videos:

python3 src/youtube_monitor_telegram.py --check

Start the interactive bot:

python3 src/telegram_bot_commands.py --run

Automated Monitoring (Cron)

Set up hourly checks by adding to your crontab:

crontab -e

Add this line (adjust paths as needed):

0 * * * * cd /path/to/youtube-monitor-bot && ./monitor.sh check >> data/logs/monitor.log 2>&1

Or run the bot in the background:

nohup ./monitor.sh bot >> data/logs/bot-commands.log 2>&1 &

Telegram Bot Commands

Send these commands to your bot on Telegram:

Command Description
/list Show all monitored channels
/add @channel Add a new channel to monitor
/remove @channel Stop monitoring a channel
/health Check system status and cron job health
/help Show help message

Examples:

/add @GregIsenberg
/add https://youtube.com/@MyFirstMillionPod
/remove @GregIsenberg

Standalone Tools

YouTube Transcript Downloader

Download transcripts from any YouTube video without API keys:

# Basic usage (readable format)
python3 src/youtube_transcript.py "https://www.youtube.com/watch?v=VIDEO_ID"

# Plain text format
python3 src/youtube_transcript.py "VIDEO_ID" --format plain

# Save to file
python3 src/youtube_transcript.py "VIDEO_ID" --output data/transcripts/video.txt

# Specify language preference
python3 src/youtube_transcript.py "VIDEO_ID" --languages en de fr

Available formats:

  • readable (default) - Clean, paragraph-formatted text
  • plain - Single continuous text
  • timestamped - Includes timestamps for each line
  • paragraphs - Auto-grouped into paragraphs
  • json - Structured JSON with timestamps

Health Check

Check the monitoring system's health status:

./monitor.sh health
# or
python3 src/healthcheck.py

Configuration Files

File Purpose
.env API keys and tokens (create from .env.example)
config/channels.txt List of YouTube channels to monitor
config/my_interests.txt Your interest profile for AI relevance scoring
data/state.json Runtime state (auto-generated)
data/video_state.json Video retry tracking (auto-generated)

Project Structure

youtube-monitor-bot/
├── src/                          # Source code
│   ├── youtube_monitor_telegram.py   # Main monitoring script
│   ├── telegram_bot_commands.py      # Interactive Telegram bot
│   ├── telegram_notifier.py          # Notification formatting & sending
│   ├── youtube_transcript.py         # Standalone transcript downloader
│   └── healthcheck.py                # System health checker
├── config/                       # User configuration
│   ├── channels.txt                  # Channels to monitor
│   └── my_interests.txt              # Your interest profile
├── data/                         # Runtime data (gitignored)
│   ├── logs/                         # Log files
│   ├── transcripts/                  # Downloaded transcripts
│   ├── summaries/                    # Generated AI summaries
│   ├── state.json                    # Channel state
│   └── video_state.json              # Video retry tracking
├── monitor.sh                    # Convenience wrapper script
├── .env.example                  # Environment template
├── requirements.txt              # Python dependencies
├── README.md                     # This file
└── LICENSE                       # MIT License

Example Notification

🎥 New video from Greg Isenberg

Building a $10M Side Project in Public

🔗 Watch on YouTube

Relevance: 9/10 ⭐⭐⭐⭐⭐

TL;DR:
Greg breaks down his strategy for building profitable side projects
by solving real problems and sharing the journey publicly.

Worth watching?
✅ YES - Packed with actionable advice and real revenue numbers

Key takeaways:
1. Started at $2K/mo MRR, now at $83K/mo in 18 months
2. Distribution strategy: Twitter threads + weekly updates
3. Used Supabase + Next.js stack to ship in 2 weeks

How AI Summaries Work

The bot uses your my_interests.txt profile to:

  1. Score relevance (1-10) based on how well the video matches your interests
  2. Generate TL;DR - One sentence summary (max 20 words)
  3. Explain why you'd care - 2-3 bullet points of relevance
  4. Extract key takeaways - Specific details, tools, numbers mentioned
  5. Recommend watching - YES/NO/MAYBE with reasoning

Troubleshooting

Bot not receiving videos:

  • Check cron job is running: ps aux | grep youtube_monitor
  • View logs: tail -f data/logs/monitor.log
  • Run manual check: ./monitor.sh check

Transcripts failing:

  • Some videos don't have transcripts immediately after upload
  • Bot will retry every hour for up to 48 hours
  • Check data/video_state.json to see retry counts

Telegram notifications not working:

  • Verify .env credentials are correct
  • Test notifications: ./monitor.sh test
  • Check bot token with @BotFather

Health check issues:

./monitor.sh health

Environment Variables

Create a .env file with these variables:

# Required for AI summaries
GEMINI_API_KEY=your_gemini_api_key_here

# Required for Telegram notifications
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_CHAT_ID=your_telegram_chat_id_here

Getting API Keys

Gemini API Key:

  1. Visit Google AI Studio
  2. Create a new API key
  3. Copy to .env

Telegram Bot:

  1. Message @BotFather on Telegram
  2. Send /newbot and follow prompts
  3. Copy the bot token to .env
  4. Get your chat ID by messaging @userinfobot

Advanced Configuration

Customizing Retry Logic

Edit src/youtube_monitor_telegram.py:39:

MAX_TRANSCRIPT_RETRIES = 48  # Number of hourly attempts

Changing Summary Model

Edit src/youtube_monitor_telegram.py:229:

model = genai.GenerativeModel('gemini-2.0-flash-exp')

Filtering Video Length

Modify the short video threshold in src/youtube_monitor_telegram.py:174:

return seconds < 300  # 300 seconds = 5 minutes

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Commit changes: git commit -am 'Add feature'
  4. Push to branch: git push origin feature-name
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

  • Open an issue for bug reports or feature requests
  • Star the repo if you find it useful

Made for staying on top of YouTube content without the noise.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published