- Python 100%
- Cache completed results by video_id to /opt/ai-services/summarizer-api/cache/ so a re-submitted URL returns instantly instead of re-running Ollama - Make endpoint async; monitor client disconnect every 2s via request.is_disconnected() - Extract sync work into _summarize_video(); check stop_event between chunks so inference aborts promptly when the client drops rather than burning CPU to completion Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| bak | ||
| .gitignore | ||
| app.py | ||
| extractors.py | ||
| README.md | ||
sauron-clipper-summary
Server-side FastAPI service running on sauron that downloads video transcripts and generates AI summaries using a local Ollama model.
How it works
Receives a URL + title from the client, detects whether it's a YouTube video or article,
downloads the transcript with yt-dlp, chunks it, summarizes each chunk with Ollama
(default: qwen2.5:7b), and returns a consolidated summary as JSON.
POST /summarize-source
{ "url": "https://youtu.be/...", "title": "...", "source_type": "auto" }
→ { "summary": "...", "video_id": "...", "original_transcript_chars": N, "sent_transcript_chars": N }
Files
app.py— FastAPI application; handles routing, chunking, Ollama calls, response assemblyextractors.py— yt-dlp wrapper that downloads subtitles/transcripts as JSON3 and parses them into clean text
Deployment
Runs on sauron at http://127.0.0.1:8008. Not exposed externally — the client reaches it
via SSH (ssh sauron 'curl ...') or an SSH tunnel (localhost:18008 → sauron:8008).
Dependencies are installed into /opt/ai-services/summarizer-api/.venv/.
Configuration (env vars)
| Variable | Default | Description |
|---|---|---|
OLLAMA_MODEL |
qwen2.5:7b |
Model used for summarization |
OLLAMA_TIMEOUT |
1200 |
Seconds before Ollama request times out |
CHUNK_TARGET_CHARS |
5000 |
Target chunk size for transcript splitting |
CHUNK_MAX_CHARS |
6500 |
Hard cap per chunk |
YT_DLP_BIN |
.venv/bin/yt-dlp |
Path to yt-dlp binary |
Client counterpart
The laptop-side automation lives at clipper-video-summary-client — scans the Obsidian zettelkasten for pending clippings and calls this API.