YouTube 每日视频总结 Telegram 机器人
This skill deploys a YouTube monitoring bot that:
- Polls configured YouTube channels via RSS feed (no API key needed for this step)
- Extracts video transcripts using
youtube-transcript-api - Falls back to audio download via
yt-dlpif no subtitles are available - Summarizes content using Google Gemini 2.5 Flash (supports both text and audio input natively)
- Sends a beautifully formatted bilingual (Chinese + English) summary to Telegram
Prerequisites
You need these three secrets configured in your environment:
GEMINI_API_KEY— from Google AI StudioTG_BOT_TOKEN— from Telegram @BotFatherTG_CHAT_ID— your personal or group Telegram chat ID
File Structure
| File | Purpose |
|---|---|
config.py | All configuration, API keys, and YouTube channel settings |
youtube_monitor.py | RSS polling and local deduplication via db.json |
extractor.py | Transcript fetching or audio download fallback |
ai_summarizer.py | Gemini API integration (text + audio) |
tg_notifier.py | Telegram message delivery with chunking |
main.py | Main entry point with daily 8:00 AM scheduling |
requirements.txt | All Python dependencies |
Setup & Usage
Step 1: Configure channels and secrets
Edit config.py and add your API keys and the YouTube Channel IDs you want to monitor:
YOUTUBE_CHANNELS = {
"UCxxxxxxxxxxxxxxxxxxxxxx": "Channel Name Here"
}
Step 2: Install dependencies
pip install -r requirements.txt
Step 3: Run
For a one-off immediate check:
python main.py
For long-running background mode (runs daily at 8 AM Izmir time):
nohup python main.py > bot.log 2>&1 &
How to Find a YouTube Channel ID
- Go to the YouTube channel page
- Click the channel name, then go to About
- Click "Share Channel" and copy the link — the ID starts with
UC... - Or use commentpicker.com/youtube-channel-id.php
Notes
- The bot tracks processed videos in
db.jsonso it never sends duplicate summaries - If Gemini API is not configured, the bot will fail gracefully with a clear error message
- Long videos with audio fallback may take 1–2 minutes to upload and process