ME4-YOUTUBE

ME4-YOUTUBE

YouTube Content Extraction Service for the ME4 suite, enabling download, metadata, transcripts, and comments via MCP, HTTP, and ZMQ interfaces.

Category
访问服务器

README

ME4-YouTube

🧠 Standards: Dieses Projekt folgt den ME4-Service-Bus-Standards v1.0.
📖 Verbindlich: HUB-Thought im openBrain — die Single source of truth.
⚠️ Abweichungen MÜSSEN in einem PR begründet werden.

ME4-Standard openBrain SOA-konform

Service-ID: ME4-YOUTUBE
Version: 1.0.0
Schnittstellen: MCP (stdio + ZMQ REQ/REP) + HTTP/REST + WSSP-15 + Framie-UI

YouTube Content Extraction Service für die ME4-Suite:

  • Download — Video- und Audio-Download via yt-dlp
  • Beschreibung — Vollständige Metadaten inkl. Description
  • Transkript — Manuell oder Auto-Generated, Multi-Language
  • Kommentare — Top-Kommentare via yt-dlp
  • Loadbalancer-MCP — Parallele Worker-Instanzen mit Health-Monitoring
  • Framie-UI — Embedded Live-Status-Display

Schnellstart

# Voraussetzungen: Python 3.11+, ffmpeg (optional, für Audio-Konvertierung)

# Klonen / Installieren
cd D:\Entwicklung\ME4-YouTube
python -m venv .venv
.venv\Scripts\activate           # Windows
# source .venv/bin/activate      # macOS/Linux
pip install -r requirements.txt

# Konfiguration (Beispiel kopieren, anpassen)
copy .env.example .env           # Windows
# cp .env.example .env           # macOS/Linux

# Starten
python main.py

# ODER (öffnet Framie-UI nicht automatisch)
python main.py --no-browser

Beim Start öffnet sich automatisch die Framie-UI im Browser unter http://localhost:8770/ui/index.html.


Schnittstellen

Schnittstelle Port Zweck
HTTP / REST 8770 Browser, Menschen, externe Tools
ZMQ Main 5570 MCP-Service-Endpoint
ZMQ Loadbalancer 5571 MCP-Loadbalancer (parallele Worker)
WSSP-15 5690 Heartbeat / Telemetrie
Worker-Pool 8771+ N parallele Worker-Instanzen (default: 2)

MCP-Tools (ZMQ + stdio)

Tool Beschreibung Auth
ping Service-Health public
get_manifest UI-Manifest für Cockpit public
health Detaillierter Status inkl. Worker-Pool public
get_status_snapshot Live-Job-Status public
get_metadata YouTube Metadaten + Description 🔑
get_transcript YouTube Transkript 🔑
get_comments YouTube Top-Kommentare 🔑
download Video/Audio herunterladen 🔑
process Komplette Pipeline (alle 4 Features) 🔑
trigger_sm_produce SM-Producer anstoßen 🔑
shutdown Geordneter Shutdown 🔑

HTTP-Endpunkte

Pfad Methode Beschreibung
/ GET Service-Info
/docs GET OpenAPI/Swagger UI
/api/health GET Health (public)
/api/manifest GET UI-Manifest (public)
/api/status GET Live-Job-Status (public)
/api/framie/stream GET SSE-Stream für Framie-UI (public)
/api/process POST Komplette Verarbeitung (🔑)
/api/metadata POST Nur Metadaten (🔑)
/api/transcript POST Nur Transkript (🔑)
/api/comments POST Nur Kommentare (🔑)
/api/download POST Video-Download (🔑)
/api/sm-produce POST SM-Producer triggern (🔑)
/ui/index.html GET Framie Live-Status-Display

🔑 = X-API-Key Header erforderlich (oder Dev-Mode wenn API_KEY="")


Beispiele

HTTP (curl)

# Metadaten + Beschreibung
curl -X POST http://localhost:8770/api/metadata \
  -H "X-API-Key: ob-youtube-key-2026" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://youtu.be/dQw4w9WgXcQ"}'

# Komplette Verarbeitung (alle Features)
curl -X POST http://localhost:8770/api/process \
  -H "X-API-Key: ob-youtube-key-2026" \
  -H "Content-Type: application/json" \
  -d '{
    "url":"https://youtu.be/dQw4w9WgXcQ",
    "download":false,
    "include_description":true,
    "include_transcript":true,
    "include_comments":true,
    "language":"de",
    "max_comments":100
  }'

ZMQ (Python)

import zmq, json

ctx = zmq.Context()
sock = ctx.socket(zmq.REQ)
sock.connect("tcp://127.0.0.1:5570")

sock.send_json({
    "jsonrpc": "2.0", "id": 1, "method": "tools/call",
    "params": {
        "name": "process",
        "arguments": {
            "url": "https://youtu.be/dQw4w9WgXcQ",
            "api_key": "ob-youtube-key-2026",
        }
    }
})
print(sock.recv_json())

MCP stdio (Claude Code / Agenten)

{
  "mcpServers": {
    "me4-youtube": {
      "command": "python",
      "args": ["D:/Entwicklung/ME4-YouTube/main.py", "--mcp-stdio"]
    }
  }
}

Loadbalancer-MCP (parallele Verarbeitung)

Der Service bringt einen eingebauten Loadbalancer-MCP mit. Agenten können Jobs direkt an den Loadbalancer schicken, der sie auf freie Worker verteilt:

sock.connect("tcp://127.0.0.1:5571")
sock.send_json({
    "jsonrpc": "2.0", "id": 1, "method": "tools/call",
    "params": {
        "name": "process",
        "arguments": {
            "url": "https://youtu.be/dQw4w9WgXcQ",
            "api_key": "ob-youtube-key-2026",
        }
    }
})

Strategien: round_robin, least_loaded, random (default: least_loaded)


SM-Producer Anbindung

Der Service kann direkt die SM-Producer-Pipeline (ME4-SMproducer-3) anstoßen:

curl -X POST http://localhost:8770/api/sm-produce \
  -H "X-API-Key: ob-youtube-key-2026" \
  -H "Content-Type: application/json" \
  -d '{
    "url":"https://youtu.be/dQw4w9WgXcQ",
    "transcript":"Volltext...",
    "language":"de",
    "workflow":"default"
  }'

Der Aufruf wird an http://localhost:3001/api/sm-produce weitergeleitet. Konfiguration via SM_PRODUCER_URL und SM_PRODUCER_API_KEY in .env.


Framie-UI

Beim Start des Services öffnet sich automatisch die Framie-UI im Browser:

  • KPIs: aktive Jobs, erledigt, Fehler, Worker-Status
  • Live-Stream über Server-Sent Events
  • Worker-Liste mit Idle/Busy/Down-Status
  • Letzte 15 Jobs in Tabelle
  • Event-Log

URL: http://localhost:8770/ui/index.html


Tests

pip install pytest pytest-asyncio
pytest

# Mit Coverage
pip install pytest-cov
pytest --cov=app --cov-report=term-missing

Konfiguration (.env)

Siehe .env.example für alle Optionen.

Wichtige Variablen:

  • API_KEY — API-Key (leer = Dev-Mode)
  • WORKER_COUNT — Anzahl paralleler Worker (default: 2)
  • LOADBALANCER_STRATEGYround_robin | least_loaded | random
  • SM_PRODUCER_URL — SM-Producer-Pipeline-URL
  • DOWNLOAD_DIR — Zielordner für Downloads

Schnittstellen-Standard

Konform zu MCP_ZMQ_STANDARD.md:

  • ZMQ REQ/REP mit JSON-RPC 2.0
  • WSSP-15 Heartbeat
  • API-Key Auth
  • UI-Manifest
  • Standard-Tools (ping, get_manifest, health, shutdown)

Architektur

┌──────────────────────────────────────────────────────────┐
│ ME4-YouTube (Service-ID: ME4-YOUTUBE)                    │
│                                                          │
│  ┌────────────────┐  ┌─────────────────┐                │
│  │  HTTP API      │  │  ZMQ Main       │                │
│  │  :8770         │  │  :5570          │                │
│  │  + Framie-UI   │  │  MCP REQ/REP    │                │
│  └────────┬───────┘  └────────┬────────┘                │
│           │                   │                         │
│           └─────────┬─────────┘                         │
│                     ▼                                   │
│           ┌─────────────────────┐                       │
│           │  WorkerPool         │                       │
│           │  (Load-Balancer)    │                       │
│           │  ZMQ :5571          │◄──── Loadbalancer-MCP  │
│           └─────────┬───────────┘                       │
│                     │                                   │
│         ┌───────────┼───────────┐                       │
│         ▼           ▼           ▼                       │
│    ┌─────────┐ ┌─────────┐ ┌─────────┐                  │
│    │worker-01│ │worker-02│ │worker-03│  (jeweils        │
│    │  :8771  │ │  :8772  │ │  :8773  │   Orchestrator)  │
│    └─────────┘ └─────────┘ └─────────┘                  │
│                                                          │
│  ┌────────────────┐  ┌─────────────────┐                │
│  │ WSSP-15 :5690  │  │  SM-Producer    │                │
│  │  Heartbeat     │  │  HTTP :3001     │                │
│  └────────────────┘  └─────────────────┘                │
└──────────────────────────────────────────────────────────┘

Jeder Worker hat:

  • eigenen HTTP-Server (für eingehende Jobs vom Loadbalancer)
  • einen Orchestrator (führt die Pipeline aus)
  • Status-Updates landen im globalen StatusTracker → Framie-Stream

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选