YouTube数据爬取服务器

一个基于AI的YouTube数据爬取和摘要生成服务器,支持多语言和云端部署。

  • by willlzl
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 glennlzl/youtube-crawler-mcp

使用说明

YouTube爬虫MCP服务器

一个用于YouTube数据爬行的模型上下文协议(MCP)服务器,具有AI支持的摘要功能。内置 FastMCP 便于作为本地和远程MCP服务器进行部署。

✨ 特性

  • 频道元数据 检索
  • AI视频摘要 带有自动转录功能(Whisper API)
  • 时间范围查询 对于视频
  • 支持带/不带字幕的视频
  • 具有智能语言检测的多语言支持
  • 双重运输:stdio(本地)和流式HTTP(远程)
  • 云就绪:部署到AWS、Google Cloud Run、Fly.io等。

🚀 快速开始

本地使用(stdio)

# Install dependencies
pip install -e .

# Configure environment
export YOUTUBE_API_KEY=your_youtube_key
export OPENAI_API_KEY=your_openai_key
export DEEPSEEK_API_KEY=your_deepseek_key

# Run with stdio (for Claude Desktop)
python main.py stdio

远程服务器(流式HTTP)

# Run HTTP server
python main.py streamable-http

# Server will start on http://0.0.0.0:8080
# Use with Claude API, Lambda, or other cloud agents

码头工人

# Build
docker build -t youtube-crawler-mcp .

# Run
docker run -p 8080:8080 \
  -e YOUTUBE_API_KEY=your_key \
  -e OPENAI_API_KEY=your_key \
  -e DEEPSEEK_API_KEY=your_key \
  youtube-crawler-mcp

MCP工具

1.获取频道元数据

{
  "username": "@channel_name"
}

2.获取最新视频摘要

{
  "username": "@channel_name",
  "n": 5,
  "include_transcript": false
}

3.按时间范围获取视频

{
  "username": "@channel_name",
  "start_date": "2024-01-01",
  "end_date": "2024-01-31",
  "max_videos": 10
}

配置

AI提供商

  • 深度求索 (推荐):0.28/1M代币输入,0.42/1M代币输出
  • 开放人工智能:GPT-4型号
  • Anthropic:克劳德模型

集 AI_PROVIDER 在 .env 更换供应商。

转录

用途 OpenAI Whisper API (0.006美元/分钟),可从YouTube元数据中自动检测语言。

Claude桌面集成

添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "youtube-crawler": {
      "command": "python",
      "args": ["-m", "src.server"],
      "cwd": "/path/to/youtubeCrawlerMcp"
    }
  }
}

Docker部署

在本地构建和运行

# Build image
docker build -t youtube-crawler-mcp .

# Run with docker-compose
docker-compose up

部署到AWS Fargate

看 部署.md 有关AWS Fargate部署的详细说明。

测试

# Test with specific channel
python test_m2story.py

成本估算

  • 转录:每30分钟约0.18美元视频(Whisper API)
  • 摘要:每个视频约0.004美元(DeepSeek)
  • 总计:每个视频约0.184美元

许可证

麻省理工学院