Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(skill): add omniget Claude Code plugin for fetch, caption and transcript

Theodore Imonigie7d572c9b0681
diff --git a/claude-plugin/.claude-plugin/marketplace.json b/claude-plugin/.claude-plugin/marketplace.json
new file mode 100644
index 00000000..d28e57e0
--- /dev/null
+++ b/claude-plugin/.claude-plugin/marketplace.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
+ "name": "omniget",
+ "description": "Claude Code plugin for OmniGet: fetch media, captions and transcripts from a pasted URL",
+ "owner": {
+ "name": "Theodore Imonigie"
+ },
+ "plugins": [
+ {
+ "name": "omniget",
+ "description": "Paste a video or post URL: download it, pull the caption, transcribe the audio locally or in the cloud, and research it. Reuses OmniGet's managed yt-dlp, ffmpeg, cookies and models when the app is installed.",
+ "source": "./omniget",
+ "category": "productivity",
+ "keywords": ["omniget", "yt-dlp", "video", "transcript", "whisper", "download"]
+ }
+ ]
+}
diff --git a/claude-plugin/.gitignore b/claude-plugin/.gitignore
new file mode 100644
index 00000000..b908d4cb
--- /dev/null
+++ b/claude-plugin/.gitignore
@@ -0,0 +1,3 @@
+__pycache__/
+*.pyc
+.DS_Store
diff --git a/claude-plugin/omniget/.claude-plugin/plugin.json b/claude-plugin/omniget/.claude-plugin/plugin.json
new file mode 100644
index 00000000..67ac0b9e
--- /dev/null
+++ b/claude-plugin/omniget/.claude-plugin/plugin.json
@@ -0,0 +1,11 @@
+{
+ "name": "omniget",
+ "version": "0.1.0",
+ "description": "Fetch media, captions and transcripts from a pasted URL with OmniGet's tooling: yt-dlp, ffmpeg, whisper.cpp or cloud speech APIs.",
+ "author": {
+ "name": "Theodore Imonigie"
+ },
+ "repository": "https://github.com/tonhowtf/omniget",
+ "license": "GPL-3.0",
+ "keywords": ["omniget", "yt-dlp", "download", "transcript", "whisper", "youtube", "instagram"]
+}
diff --git a/claude-plugin/omniget/README.md b/claude-plugin/omniget/README.md
new file mode 100644
index 00000000..25af7159
--- /dev/null
+++ b/claude-plugin/omniget/README.md
@@ -0,0 +1,77 @@
+# OmniGet — Claude Code plugin
+
+Paste a video, audio, or social-post URL into Claude Code and get the media file,
+its caption, and a transcript, ready to summarize, quote, or research.
+
+It reuses whatever OmniGet already installed. Tool lookup order, mirroring the
+desktop app's own resolver: `omniget-cli` on `PATH` → the binaries OmniGet
+manages in its app-data folder → the system `PATH`. Nothing here requires the
+desktop app; with `yt-dlp` and `ffmpeg` on `PATH` it works on its own.
+
+## Install
+
+```
+/plugin marketplace add /path/to/omniget/claude-plugin
+/plugin install omniget
+```
+
+Then run `/omniget:doctor` to see what is available and what to add.
+
+## Commands
+
+| Command | Does |
+|---|---|
+| `/omniget:fetch <url> [--audio] [--quality N]` | Download the media to `~/Downloads/omniget` |
+| `/omniget:transcribe <url\|file> [--backend B] [--lang xx] [--summarize]` | Transcribe and optionally summarize |
+| `/omniget:research <url> [--backend B]` | Caption + transcript distilled into a Markdown note with `[mm:ss]` references |
+| `/omniget:doctor` | Report available tools, models, and keys, plus how to add the missing ones |
+
+The two skills (`omniget-fetch`, `omniget-transcribe`) trigger on their own when a
+media URL is pasted with a request, so the slash commands are optional.
+
+## Transcription backends
+
+`--backend auto` (the default) walks this ladder and uses the first that works:
+
+1. **captions** — platform subtitles via `yt-dlp`. Free, instant.
+2. **local** — `whisper-cli` (whisper.cpp) with a ggml model. Free, offline, private.
+3. **mlx** — `mlx_whisper` on Apple Silicon. Free, offline, faster than whisper-cli.
+4. **gemini** — Gemini 2.5 Flash, needs `GEMINI_API_KEY`. Cents per hour, audio-native.
+5. **openai** — needs `OPENAI_API_KEY`. `whisper-1` returns timestamps; `--model gpt-4o-transcribe` is more accurate but text-only.
+
+Force one with `--backend local|mlx|gemini|openai|captions`. API keys are read from
+the environment or `~/.config/ai-keys.env` and never printed.
+
+## Getting the pieces
+
+Nothing is installed for you; `/omniget:doctor` prints the commands and you decide.
+
+- **yt-dlp + ffmpeg**: `brew install yt-dlp ffmpeg` (macOS), `winget install yt-dlp.yt-dlp Gyan.FFmpeg` (Windows), your distro's packages (Linux).
+- **local Whisper**: `brew install whisper-cpp`, or the release bundle from `ggml-org/whisper.cpp`. On Apple Silicon `uv tool install mlx-whisper` is faster.
+- **a model**: `scripts/get-model.sh large-v3-turbo-q5_0` (547 MB, SHA-256 verified from `ggerganov/whisper.cpp`). Smaller: `base` (141 MB), `small` (465 MB).
+- **cloud keys**: `export GEMINI_API_KEY=...` / `export OPENAI_API_KEY=...`, or put them in `~/.config/ai-keys.env`.
+
+## Environment variables
+
+| Variable | Meaning |
+|---|---|
+| `OMNIGET_DIR` | Output directory (default `~/Downloads/omniget`) |
+| `OMNIGET_DATA_DIR` | OmniGet app-data dir (auto-detected per OS) |
+| `OMNIGET_TOOL_YT_DLP`, `OMNIGET_TOOL_FFMPEG`, ... | Explicit binary paths |
+| `OMNIGET_WHISPER_MODEL` | Explicit ggml model file for the local backend |
+| `OMNIGET_COOKIES_FROM_BROWSER` | `chrome` / `firefox` / `safari` / `edge` for login-gated media |
+| `OMNIGET_KEYS_FILE` | Alternative to `~/.config/ai-keys.env` |
+
+## Scripts
+
+The skills call `scripts/`; each prints one JSON line on success, progress on stderr:
+`doctor.sh`, `resolve-tools.sh` (shared lookup, sourced by the rest), `fetch.sh`,
+`research.sh`, `transcribe.sh`, `get-model.sh`, plus `srt_tools.py`,
+`gemini_transcribe.py`, `openai_transcribe.sh`. Run the tests with
+`python3 -m unittest discover -s tests`.
+
+## Scope
+
+Downloads only what the user asks for. Never bypasses DRM or paywalls; it uses the
+session the user already has (via OmniGet cookie accounts or `--cookies-from-browser`).
+Captions cover the post description; comments are out of scope.
diff --git a/claude-plugin/omniget/commands/doctor.md b/claude-plugin/omniget/commands/doctor.md
new file mode 100644
index 00000000..e4169667
--- /dev/null
+++ b/claude-plugin/omniget/commands/doctor.md
@@ -0,0 +1,9 @@
+---
+description: Check which OmniGet tools, Whisper models and speech API keys this machine has, and how to add missing ones
+allowed-tools: ["Bash"]
+---
+
+Run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/doctor.sh"` and explain the result in plain words:
+what works today (captions, local Whisper, Gemini, OpenAI), what is missing, and the exact
+command that would add each missing piece. Do not run any install command unless the user
+answers yes.
diff --git a/claude-plugin/omniget/commands/fetch.md b/claude-plugin/omniget/commands/fetch.md
new file mode 100644
index 00000000..9278bea7
--- /dev/null
+++ b/claude-plugin/omniget/commands/fetch.md
@@ -0,0 +1,16 @@
+---
+description: Download the media at a URL with OmniGet's tooling (yt-dlp, ffmpeg, omniget-cli)
+argument-hint: <url> [--audio] [--quality N] [--out DIR]
+allowed-tools: ["Bash", "Read"]
+---
+
+Download the media for the arguments below using the `omniget-fetch` skill.
+
+Run:
+```bash
+bash "${CLAUDE_PLUGIN_ROOT}/scripts/fetch.sh" $ARGUMENTS
+```
+
+Then report the saved file path, size and duration in one or two sentences. If the script
+fails, run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/doctor.sh"`, apply the error table from the
+`omniget-fetch` skill, and ask before installing anything.
diff --git a/claude-plugin/omniget/commands/research.md b/claude-plugin/omniget/commands/research.md
new file mode 100644
index 00000000..4f7ff7f7
--- /dev/null
+++ b/claude-plugin/omniget/commands/research.md
@@ -0,0 +1,14 @@
+---
+description: "Research a video or post URL: caption plus transcript, distilled into a Markdown note with timestamps"
+argument-hint: <url> [--backend auto|local|mlx|gemini|openai] [--lang xx]
+allowed-tools: ["Bash", "Read", "Write"]
+---
+
+Build a research note for the URL in the arguments using the `omniget-transcribe` skill.
+
+1. `bash "${CLAUDE_PLUGIN_ROOT}/scripts/research.sh" "<url>"` for title, uploader, duration and caption.
+2. `bash "${CLAUDE_PLUGIN_ROOT}/scripts/transcribe.sh" <arguments>` for the transcript.
+3. Read the transcript file. Write `<transcript path without .md>.notes.md` containing:
+ title and source link; the caption verbatim when present; a five-line summary; key points
+ with `[mm:ss]` references; notable quotes with timestamps; open questions worth checking.
+4. Reply with the note's path and the summary. Mention which backend produced the transcript.
diff --git a/claude-plugin/omniget/commands/transcribe.md b/claude-plugin/omniget/commands/transcribe.md
new file mode 100644
index 00000000..757a448d
--- /dev/null
+++ b/claude-plugin/omniget/commands/transcribe.md
@@ -0,0 +1,15 @@
+---
+description: Transcribe a video/audio URL or local file (captions, local Whisper, Gemini or OpenAI) and summarize on request
+argument-hint: <url|file> [--backend auto|local|mlx|gemini|openai] [--lang xx] [--summarize]
+allowed-tools: ["Bash", "Read", "Write"]
+---
+
+Transcribe the media in the arguments below using the `omniget-transcribe` skill.
+
+1. If `--summarize` is present, remove it from the arguments and remember to summarize.
+2. For a URL, first run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/research.sh" "<url>"` to get the
+ title and caption.
+3. Run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/transcribe.sh" <remaining arguments>`.
+4. Read the transcript file named in the JSON output.
+5. Reply with the transcript path, the backend used, and, when asked, a summary with
+ `[mm:ss]` references. Otherwise give a two-sentence description of the content.
diff --git a/claude-plugin/omniget/scripts/doctor.sh b/claude-plugin/omniget/scripts/doctor.sh
new file mode 100755
index 00000000..77124cdd
--- /dev/null
+++ b/claude-plugin/omniget/scripts/doctor.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+# Report which tools, models and keys the omniget skill can use, and how to get the missing ones.
+# Usage: doctor.sh [--json]
+set -u
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+# shellcheck source=resolve-tools.sh
+. "$here/resolve-tools.sh"
+
+json=false
+[ "${1:-}" = "--json" ] && json=true
+
+rows=""
+add_row() { rows="$rows$1 $2 $3
+"; }
+
+for t in omniget-cli yt-dlp ffmpeg ffprobe whisper-cli mlx_whisper; do
+ if found="$(og_find_tool "$t")"; then
+ add_row "$t" "$(printf '%s' "$found" | cut -f2)" "$(printf '%s' "$found" | cut -f1)"
+ else
+ add_row "$t" missing -
+ fi
+done
+
+if model="$(og_whisper_model)"; then
+ add_row whisper-model present "$model"
+else
+ add_row whisper-model missing -
+fi
+
+for k in GEMINI_API_KEY OPENAI_API_KEY; do
+ if og_has_key "$k"; then add_row "$k" present "(set)"; else add_row "$k" missing -; fi
+done
+
+data="$(og_data_dir)"
+if [ -d "$data" ]; then add_row omniget-app installed "$data"; else add_row omniget-app missing "$data"; fi
+add_row output-dir configured "$(og_output_dir)"
+
+if $json; then
+ printf '{'
+ first=true
+ printf '%s' "$rows" | while IFS=' ' read -r name status where; do
+ [ -n "$name" ] || continue
+ $first || printf ','
+ first=false
+ printf '"%s":{"status":"%s","path":"%s"}' "$name" "$status" "$(printf '%s' "$where" | sed 's/\\/\\\\/g; s/"/\\"/g')"
+ done
+ printf '}\n'
+ exit 0
+fi
+
+printf '%-16s %-10s %s\n' TOOL STATUS WHERE
+printf '%s' "$rows" | while IFS=' ' read -r name status where; do
+ [ -n "$name" ] || continue
+ printf '%-16s %-10s %s\n' "$name" "$status" "$where"
+done
+
+echo
+echo "How to fill gaps (ask the user before running any of these):"
+case "$(og_os)" in
+ mac)
+ echo " OmniGet app: https://github.com/tonhowtf/omniget/releases/latest (.dmg; then: xattr -cr /Applications/omniget.app)"
+ echo " yt-dlp + ffmpeg: brew install yt-dlp ffmpeg"
+ echo " local whisper: brew install whisper-cpp (whisper.cpp CLI, CPU/Metal)"
+ echo " uv tool install mlx-whisper (faster on Apple Silicon)"
+ ;;
+ linux)
+ echo " OmniGet app: https://github.com/tonhowtf/omniget/releases/latest (.deb/.rpm/.AppImage)"
+ echo " yt-dlp + ffmpeg: sudo apt install ffmpeg && pip install -U yt-dlp (or your distro's packages)"
+ echo " local whisper: whisper-bin-ubuntu-x64.tar.gz from https://github.com/ggml-org/whisper.cpp/releases"
+ ;;
+ windows)
+ echo " OmniGet app: winget install -e --id tonhowtf.OmniGet"
+ echo " yt-dlp + ffmpeg: winget install yt-dlp.yt-dlp Gyan.FFmpeg"
+ echo " local whisper: whisper-bin-x64.zip from https://github.com/ggml-org/whisper.cpp/releases"
+ ;;
+esac
+echo " whisper model: $here/get-model.sh large-v3-turbo-q5_0 (547 MB, from ggerganov/whisper.cpp on Hugging Face)"
+echo " cloud keys: export GEMINI_API_KEY=... or OPENAI_API_KEY=..., or put them in ~/.config/ai-keys.env"
diff --git a/claude-plugin/omniget/scripts/fetch.sh b/claude-plugin/omniget/scripts/fetch.sh
new file mode 100755
index 00000000..4b03ad02
--- /dev/null
+++ b/claude-plugin/omniget/scripts/fetch.sh
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+# Download media from a URL. Prints one JSON line: {file,title,duration,size,platform,engine,id}.
+# Usage: fetch.sh <url> [--audio] [--quality 720] [--out DIR]
+set -eu
+set -o pipefail
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+. "$here/resolve-tools.sh"
+
+url=""; audio=false; quality=""; out=""
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --audio) audio=true ;;
+ --quality) quality="$2"; shift ;;
+ --out) out="$2"; shift ;;
+ -*) echo "fetch: unknown flag $1" >&2; exit 2 ;;
+ *) url="$1" ;;
+ esac
+ shift
+done
+[ -n "$url" ] || { echo "usage: fetch.sh <url> [--audio] [--quality N] [--out DIR]" >&2; exit 2; }
+[ -n "$out" ] || out="$(og_output_dir)"
+mkdir -p "$out"
+
+file_size() {
+ if stat -f%z "$1" >/dev/null 2>&1; then stat -f%z "$1"; else stat -c%s "$1"; fi
+}
+
+# omniget-cli path: native extractors and OmniGet cookie accounts for the hosts that need them.
+if og_prefers_cli "$url" && cli="$(og_tool_path omniget-cli)"; then
+ info="$("$cli" --json info "$url")"
+ args=(--json download "$url" -o "$out")
+ $audio && args+=(--audio-only)
+ [ -n "$quality" ] && args+=(-q "$quality")
+ result="$("$cli" "${args[@]}" | tail -n 1)"
+ printf '%s\n%s\n' "$info" "$result" | python3 -c '
+import json, sys
+info, result = [json.loads(l) for l in sys.stdin.read().splitlines() if l.strip()][:2]
+if not result.get("success"):
+ sys.exit("fetch: omniget-cli failed: %s" % result.get("error"))
+print(json.dumps({
+ "file": result["file_path"], "title": info.get("title"), "duration": info.get("duration"),
+ "size": result.get("size"), "platform": result.get("platform"), "engine": "omniget-cli",
+}, ensure_ascii=False))'
+ exit 0
+fi
+
+ytdlp="$(og_tool_path yt-dlp)" || { echo "fetch: yt-dlp not found; run doctor.sh" >&2; exit 1; }
+ffmpeg_dir=""
+if ffmpeg="$(og_tool_path ffmpeg)"; then ffmpeg_dir="$(dirname "$ffmpeg")"; fi
+
+args=(--no-warnings --no-playlist --no-simulate --quiet
+ --print "%(id)s ||| %(extractor_key)s ||| %(duration)s ||| %(title)s"
+ --print "after_move:filepath"
+ -o "$out/%(title).120B [%(id)s].%(ext)s")
+[ -n "$ffmpeg_dir" ] && args+=(--ffmpeg-location "$ffmpeg_dir")
+if $audio; then
+ args+=(-f "bestaudio/best" -x --audio-format m4a)
+elif [ -n "$quality" ]; then
+ args+=(-f "bv*[height<=$quality]+ba/b[height<=$quality]/b" --merge-output-format mp4)
+else
+ args+=(-f "bv*+ba/b" --merge-output-format mp4)
+fi
+while IFS= read -r line; do args+=("$line"); done < <(og_cookie_args "$url")
+
+output="$("$ytdlp" "${args[@]}" "$url")"
+meta="$(printf '%s\n' "$output" | head -n 1)"
+path="$(printf '%s\n' "$output" | tail -n 1)"
+[ -f "$path" ] || { echo "fetch: download finished but file not found: $path" >&2; exit 1; }
+
+id="$(printf '%s' "$meta" | awk -F' \\|\\|\\| ' '{print $1}')"
+platform="$(printf '%s' "$meta" | awk -F' \\|\\|\\| ' '{print $2}')"
+duration="$(printf '%s' "$meta" | awk -F' \\|\\|\\| ' '{print $3}')"
+title="$(printf '%s' "$meta" | awk -F' \\|\\|\\| ' '{print $4}')"
+[ "$duration" = "NA" ] && duration=""
+og_json file="$path" title="$title" duration:n="$duration" size:n="$(file_size "$path")" platform="$platform" engine="yt-dlp" id="$id"
diff --git a/claude-plugin/omniget/scripts/gemini_transcribe.py b/claude-plugin/omniget/scripts/gemini_transcribe.py
new file mode 100755
index 00000000..6cb4038c
--- /dev/null
+++ b/claude-plugin/omniget/scripts/gemini_transcribe.py
@@ -0,0 +1,183 @@
+#!/usr/bin/env python3
+"""Transcribe an audio file with Gemini and write SubRip (SRT) output.
+
+Usage: gemini_transcribe.py AUDIO --out OUT.srt [--model gemini-2.5-flash] [--lang xx]
+
+Reads GEMINI_API_KEY from the environment. Standard library only: files up to
+19 MB are sent inline, larger ones go through the Gemini Files API. If the
+model does not return parseable SRT, the raw text is written to OUT with a
+.txt extension and that path is printed instead.
+"""
+import argparse
+import base64
+import json
+import mimetypes
+import os
+import re
+import sys
+import time
+import urllib.error
+import urllib.request
+
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+import srt_tools # noqa: E402
+
+API = "https://generativelanguage.googleapis.com"
+INLINE_LIMIT = 19 * 1024 * 1024
+
+PROMPT = (
+ "Transcribe this audio verbatim into SubRip (SRT) subtitle format. "
+ "Number every cue, use `HH:MM:SS,mmm --> HH:MM:SS,mmm` timestamps that match "
+ "when the words are spoken, keep each cue under about 10 seconds, and write "
+ "exactly what is said with no commentary, no speaker guesses and no markdown fences. {lang}"
+)
+
+
+def normalize_srt_timestamps(text):
+ """Rewrite the timestamp lines Gemini emits into strict SRT `HH:MM:SS,mmm`.
+
+ Gemini is inconsistent: it produces `MM:SS:mmm`, `HH:MM:SS.mmm`, bare
+ `HH:MM:SS`, and the correct comma form interchangeably. Normalize every
+ `-->` line so srt_tools.parse_cues can read it.
+ """
+ def one(token):
+ parts = [p for p in re.split(r"[:.,]", token.strip()) if p != ""]
+ if not parts:
+ return None
+ ms = 0
+ if len(parts) > 1 and len(parts[-1]) == 3 and parts[-1].isdigit():
+ ms = int(parts[-1])
+ parts = parts[:-1]
+ try:
+ nums = [int(p) for p in parts]
+ except ValueError:
+ return None
+ s = nums[-1] if len(nums) >= 1 else 0
+ m = nums[-2] if len(nums) >= 2 else 0
+ h = nums[-3] if len(nums) >= 3 else 0
+ return "%02d:%02d:%02d,%03d" % (h, m, s, ms)
+
+ out = []
+ for line in text.splitlines():
+ if "-->" in line:
+ m = re.match(r"\s*([0-9:.,]+)\s*-->\s*([0-9:.,]+)(.*)$", line)
+ if m:
+ a, b = one(m.group(1)), one(m.group(2))
+ if a and b:
+ line = "%s --> %s" % (a, b)
+ out.append(line)
+ return "\n".join(out)
+
+
+
+def request(method, url, body=None, headers=None, raw=False, timeout=900):
+ data = body if raw else (json.dumps(body).encode() if body is not None else None)
+ hdrs = {"Content-Type": "application/json"}
+ hdrs.update(headers or {})
+ req = urllib.request.Request(url, data=data, method=method, headers=hdrs)
+ for attempt in range(4):
+ try:
+ with urllib.request.urlopen(req, timeout=timeout) as resp:
+ return resp.headers, resp.read()
+ except urllib.error.HTTPError as err:
+ detail = err.read().decode(errors="replace")[:500]
+ if err.code in (429, 500, 502, 503, 504) and attempt < 3:
+ time.sleep(5 * (attempt + 1))
+ continue
+ sys.exit("gemini: HTTP %s: %s" % (err.code, detail))
+ except urllib.error.URLError as err:
+ if attempt < 3:
+ time.sleep(5 * (attempt + 1))
+ continue
+ sys.exit("gemini: %s" % err)
+
+
+def upload_file(path, mime, key):
+ size = os.path.getsize(path)
+ headers, _ = request(
+ "POST",
+ "%s/upload/v1beta/files?key=%s" % (API, key),
+ {"file": {"display_name": os.path.basename(path)}},
+ {
+ "X-Goog-Upload-Protocol": "resumable",
+ "X-Goog-Upload-Command": "start",
+ "X-Goog-Upload-Header-Content-Length": str(size),
+ "X-Goog-Upload-Header-Content-Type": mime,
+ },
+ )
+ upload_url = headers.get("X-Goog-Upload-URL")
+ if not upload_url:
+ sys.exit("gemini: upload session did not return an upload URL")
+ with open(path, "rb") as fh:
+ payload = fh.read()
+ _, body = request(
+ "POST",
+ upload_url,
+ payload,
+ {
+ "Content-Type": mime,
+ "X-Goog-Upload-Offset": "0",
+ "X-Goog-Upload-Command": "upload, finalize",
+ },
+ raw=True,
+ )
+ info = json.loads(body)["file"]
+ name, uri = info["name"], info["uri"]
+ while info.get("state") == "PROCESSING":
+ time.sleep(3)
+ _, body = request("GET", "%s/v1beta/%s?key=%s" % (API, name, key))
+ info = json.loads(body)
+ if info.get("state") == "FAILED":
+ sys.exit("gemini: file processing failed")
+ return uri
+
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ ap.add_argument("audio")
+ ap.add_argument("--out", required=True)
+ ap.add_argument("--model", default="gemini-2.5-flash")
+ ap.add_argument("--lang", default="")
+ args = ap.parse_args()
+
+ key = os.environ.get("GEMINI_API_KEY") or os.environ.get("GOOGLE_API_KEY")
+ if not key:
+ sys.exit("gemini: GEMINI_API_KEY is not set")
+
+ mime = mimetypes.guess_type(args.audio)[0] or "audio/mpeg"
+ if os.path.getsize(args.audio) <= INLINE_LIMIT:
+ with open(args.audio, "rb") as fh:
+ media = {"inline_data": {"mime_type": mime, "data": base64.b64encode(fh.read()).decode()}}
+ else:
+ media = {"file_data": {"mime_type": mime, "file_uri": upload_file(args.audio, mime, key)}}
+
+ lang_hint = ("The audio is in %s." % args.lang) if args.lang else "Keep the spoken language."
+ body = {
+ "contents": [{"parts": [{"text": PROMPT.format(lang=lang_hint)}, media]}],
+ "generationConfig": {"temperature": 0, "maxOutputTokens": 65536},
+ }
+ _, raw = request("POST", "%s/v1beta/models/%s:generateContent?key=%s" % (API, args.model, key), body)
+ reply = json.loads(raw)
+ candidates = reply.get("candidates") or []
+ if not candidates:
+ sys.exit("gemini: empty response: %s" % json.dumps(reply)[:300])
+ text = "".join(p.get("text", "") for p in candidates[0].get("content", {}).get("parts", []))
+ text = text.strip()
+ if text.startswith("```"):
+ text = text.strip("`")
+ text = text.split("\n", 1)[1] if "\n" in text else text
+
+ cues = srt_tools.parse_cues(normalize_srt_timestamps(text))
+ if cues:
+ out = args.out
+ with open(out, "w", encoding="utf-8") as fh:
+ fh.write(srt_tools.render_srt(cues))
+ else:
+ out = os.path.splitext(args.out)[0] + ".txt"
+ with open(out, "w", encoding="utf-8") as fh:
+ fh.write(text + "\n")
+ print(out)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/claude-plugin/omniget/scripts/get-model.sh b/claude-plugin/omniget/scripts/get-model.sh
new file mode 100755
index 00000000..623be64d
--- /dev/null
+++ b/claude-plugin/omniget/scripts/get-model.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+# Download a whisper.cpp ggml model from Hugging Face (ggerganov/whisper.cpp) and verify its SHA-256.
+# Usage: get-model.sh <name> e.g. large-v3-turbo-q5_0 (547 MB), base (141 MB), small (465 MB)
+# Destination: OmniGet's models/whisper dir when it exists, else ~/.cache/omniget-skill/models.
+set -eu
+set -o pipefail
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+. "$here/resolve-tools.sh"
+
+name="${1:?usage: get-model.sh <model-name>}"
+name="${name#ggml-}"; name="${name%.bin}"
+file="ggml-$name.bin"
+
+dest_dir="$(og_data_dir)/models/whisper"
+[ -d "$dest_dir" ] || dest_dir="$(og_skill_cache_dir)/models"
+mkdir -p "$dest_dir"
+dest="$dest_dir/$file"
+if [ -f "$dest" ]; then
+ echo "$dest"
+ exit 0
+fi
+
+expected="$(curl -sSf -m 30 "https://huggingface.co/api/models/ggerganov/whisper.cpp/tree/main" \
+ | python3 -c 'import json,sys; want=sys.argv[1]
+for e in json.load(sys.stdin):
+ if e.get("path")==want: print((e.get("lfs") or {}).get("oid","")); break' "$file")"
+[ -n "$expected" ] || { echo "get-model: $file is not in ggerganov/whisper.cpp" >&2; exit 1; }
+
+tmp="$dest.part"
+echo "Downloading $file to $dest_dir ..." >&2
+curl -L --fail --progress-bar -o "$tmp" "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/$file"
+
+if command -v sha256sum >/dev/null 2>&1; then
+ actual="$(sha256sum "$tmp" | cut -d' ' -f1)"
+else
+ actual="$(shasum -a 256 "$tmp" | cut -d' ' -f1)"
+fi
+if [ "$actual" != "$expected" ]; then
+ rm -f "$tmp"
+ echo "get-model: SHA-256 mismatch for $file (expected $expected, got $actual)" >&2
+ exit 1
+fi
+mv "$tmp" "$dest"
+echo "$dest"
diff --git a/claude-plugin/omniget/scripts/openai_transcribe.sh b/claude-plugin/omniget/scripts/openai_transcribe.sh
new file mode 100755
index 00000000..d7a602e5
--- /dev/null
+++ b/claude-plugin/omniget/scripts/openai_transcribe.sh
@@ -0,0 +1,77 @@
+#!/usr/bin/env bash
+# Transcribe an audio file with OpenAI's /v1/audio/transcriptions and write SRT (whisper-1)
+# or plain text (gpt-4o-transcribe, gpt-4o-mini-transcribe). Files over 24 MB are split into
+# 20-minute parts and stitched back with time offsets. Prints the output path.
+# Usage: openai_transcribe.sh AUDIO --out OUT.srt [--model whisper-1] [--lang xx]
+set -eu
+set -o pipefail
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+. "$here/resolve-tools.sh"
+
+audio=""; out=""; model="whisper-1"; lang=""
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --out) out="$2"; shift ;;
+ --model) model="$2"; shift ;;
+ --lang) lang="$2"; shift ;;
+ -*) echo "openai_transcribe: unknown flag $1" >&2; exit 2 ;;
+ *) audio="$1" ;;
+ esac
+ shift
+done
+[ -n "$audio" ] && [ -n "$out" ] || { echo "usage: openai_transcribe.sh AUDIO --out OUT.srt [--model M] [--lang xx]" >&2; exit 2; }
+og_load_keys
+[ -n "${OPENAI_API_KEY:-}" ] || { echo "openai_transcribe: OPENAI_API_KEY is not set" >&2; exit 1; }
+
+case "$model" in
+ whisper-1) fmt=srt; ext=srt ;;
+ *) fmt=text; ext=txt ;;
+esac
+[ "$ext" = txt ] && out="${out%.*}.txt"
+
+file_size() { if stat -f%z "$1" >/dev/null 2>&1; then stat -f%z "$1"; else stat -c%s "$1"; fi; }
+tmp="$(mktemp -d "${TMPDIR:-/tmp}/omniget-openai.XXXXXX")"
+trap 'rm -rf "$tmp"' EXIT
+
+transcribe_one() {
+ local part="$1" dest="$2" attempt
+ for attempt in 1 2 3; do
+ if curl -sS --fail --max-time 900 https://api.openai.com/v1/audio/transcriptions \
+ -H "Authorization: Bearer $OPENAI_API_KEY" \
+ -F "file=@$part" -F "model=$model" -F "response_format=$fmt" \
+ ${lang:+-F "language=$lang"} -o "$dest"; then
+ return 0
+ fi
+ echo "openai_transcribe: attempt $attempt failed, retrying" >&2
+ sleep $((attempt * 5))
+ done
+ return 1
+}
+
+if [ "$(file_size "$audio")" -le $((24 * 1024 * 1024)) ]; then
+ transcribe_one "$audio" "$out"
+ echo "$out"
+ exit 0
+fi
+
+ffmpeg="$(og_tool_path ffmpeg)" || { echo "openai_transcribe: ffmpeg needed to split large audio" >&2; exit 1; }
+ffprobe="$(og_tool_path ffprobe)" || ffprobe="$(dirname "$ffmpeg")/ffprobe"
+"$ffmpeg" -v error -y -i "$audio" -f segment -segment_time 1200 -c copy "$tmp/part%03d.${audio##*.}"
+
+offset=0
+parts=()
+for part in "$tmp"/part*; do
+ dest="$tmp/$(basename "${part%.*}").$ext"
+ transcribe_one "$part" "$dest"
+ parts+=("$dest:$offset")
+ dur="$("$ffprobe" -v error -show_entries format=duration -of csv=p=0 "$part")"
+ offset="$(python3 -c "print($offset + $dur)")"
+done
+
+if [ "$ext" = srt ]; then
+ python3 "$here/srt_tools.py" concat --out "$out" "${parts[@]}"
+else
+ : > "$out"
+ for spec in "${parts[@]}"; do cat "${spec%:*}" >> "$out"; printf '\n' >> "$out"; done
+fi
+echo "$out"
diff --git a/claude-plugin/omniget/scripts/research.sh b/claude-plugin/omniget/scripts/research.sh
new file mode 100755
index 00000000..6e8f7d15
--- /dev/null
+++ b/claude-plugin/omniget/scripts/research.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+# Describe a media URL without downloading it. Prints one JSON line:
+# {title, platform, uploader, duration, url, caption?, has_captions, thumbnail?, upload_date?}
+# `caption` is the post text / description and is omitted when the platform provides none.
+# Usage: research.sh <url>
+set -eu
+set -o pipefail
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+. "$here/resolve-tools.sh"
+
+url="${1:?usage: research.sh <url>}"
+ytdlp="$(og_tool_path yt-dlp)" || { echo "research: yt-dlp not found; run doctor.sh" >&2; exit 1; }
+args=(-J --no-warnings --no-playlist)
+while IFS= read -r line; do args+=("$line"); done < <(og_cookie_args "$url")
+
+"$ytdlp" "${args[@]}" "$url" | python3 -c '
+import json, sys
+info = json.load(sys.stdin)
+if info.get("_type") == "playlist":
+ entries = info.get("entries") or []
+ info = entries[0] if entries else info
+caption = (info.get("description") or "").strip()
+out = {
+ "title": info.get("title"),
+ "platform": info.get("extractor_key"),
+ "uploader": info.get("uploader") or info.get("channel") or info.get("uploader_id"),
+ "duration": info.get("duration"),
+ "url": info.get("webpage_url") or sys.argv[1],
+ "has_captions": bool(info.get("subtitles")) or bool(info.get("automatic_captions")),
+ "thumbnail": info.get("thumbnail"),
+ "upload_date": info.get("upload_date"),
+}
+if caption:
+ out["caption"] = caption
+print(json.dumps({k: v for k, v in out.items() if v not in (None, "")}, ensure_ascii=False))' "$url"
diff --git a/claude-plugin/omniget/scripts/resolve-tools.sh b/claude-plugin/omniget/scripts/resolve-tools.sh
new file mode 100755
index 00000000..05a1e1c7
--- /dev/null
+++ b/claude-plugin/omniget/scripts/resolve-tools.sh
@@ -0,0 +1,213 @@
+#!/usr/bin/env bash
+# Locate the tools the omniget skill relies on, preferring OmniGet's own copies.
+#
+# Lookup order mirrors OmniGet's find_tool_with_source:
+# 1. explicit override OMNIGET_TOOL_<NAME>=/path (e.g. OMNIGET_TOOL_YT_DLP)
+# 2. OmniGet managed dir <data dir>/bin (source "omniget")
+# 3. PATH (source "system")
+#
+# Usage: resolve-tools.sh [tool ...] prints "name<TAB>path<TAB>source" per tool
+# . resolve-tools.sh then call og_find_tool / og_whisper_model / og_load_keys
+#
+# Bash 3.2 compatible (macOS default shell).
+
+og_os() {
+ case "$(uname -s)" in
+ Darwin) echo mac ;;
+ Linux) echo linux ;;
+ MINGW*|MSYS*|CYGWIN*) echo windows ;;
+ *) echo other ;;
+ esac
+}
+
+# OmniGet's app data directory (see omniget-core/src/core/paths.rs).
+og_data_dir() {
+ if [ -n "${OMNIGET_DATA_DIR:-}" ]; then
+ echo "$OMNIGET_DATA_DIR"
+ return
+ fi
+ case "$(og_os)" in
+ mac) echo "$HOME/Library/Application Support/wtf.tonho.omniget" ;;
+ linux) echo "${XDG_DATA_HOME:-$HOME/.local/share}/wtf.tonho.omniget" ;;
+ windows) echo "${APPDATA:-$HOME/AppData/Roaming}/wtf.tonho.omniget" ;;
+ *) echo "$HOME/.omniget" ;;
+ esac
+}
+
+# Where the skill keeps its own downloads (models) when OmniGet has none.
+og_skill_cache_dir() {
+ echo "${OMNIGET_SKILL_CACHE:-$HOME/.cache/omniget-skill}"
+}
+
+# Output directory for media and transcripts.
+og_output_dir() {
+ echo "${OMNIGET_DIR:-$HOME/Downloads/omniget}"
+}
+
+og_exe() {
+ if [ "$(og_os)" = windows ]; then echo "$1.exe"; else echo "$1"; fi
+}
+
+# og_find_tool NAME -> prints "path<TAB>source", exit 1 when missing.
+og_find_tool() {
+ local name="$1" var path alt
+ var="OMNIGET_TOOL_$(printf '%s' "$name" | tr 'a-z-' 'A-Z_')"
+ path="$(eval "printf '%s' \"\${$var:-}\"")"
+ if [ -n "$path" ] && [ -x "$path" ]; then
+ printf '%s\tcustom\n' "$path"
+ return 0
+ fi
+ path="$(og_data_dir)/bin/$(og_exe "$name")"
+ if [ -x "$path" ]; then
+ printf '%s\tomniget\n' "$path"
+ return 0
+ fi
+ if path="$(command -v "$name" 2>/dev/null)"; then
+ printf '%s\tsystem\n' "$path"
+ return 0
+ fi
+ # Homebrew's older formula installed the whisper.cpp CLI as whisper-cpp.
+ if [ "$name" = whisper-cli ] && alt="$(command -v whisper-cpp 2>/dev/null)"; then
+ printf '%s\tsystem\n' "$alt"
+ return 0
+ fi
+ return 1
+}
+
+og_tool_path() {
+ og_find_tool "$1" | cut -f1
+}
+
+# Best available ggml model for whisper-cli. Preference: large-v3-turbo (quantised first),
+# then medium, small, base, tiny. Looks in OmniGet's models dir, then the skill cache.
+og_whisper_model() {
+ local dir candidate
+ if [ -n "${OMNIGET_WHISPER_MODEL:-}" ] && [ -f "$OMNIGET_WHISPER_MODEL" ]; then
+ echo "$OMNIGET_WHISPER_MODEL"
+ return 0
+ fi
+ for dir in "$(og_data_dir)/models/whisper" "$(og_skill_cache_dir)/models"; do
+ [ -d "$dir" ] || continue
+ for candidate in \
+ ggml-large-v3-turbo-q5_0.bin ggml-large-v3-turbo-q8_0.bin ggml-large-v3-turbo.bin \
+ ggml-large-v3-q5_0.bin ggml-large-v3.bin \
+ ggml-medium-q5_0.bin ggml-medium-q8_0.bin ggml-medium.bin \
+ ggml-small-q5_1.bin ggml-small-q8_0.bin ggml-small.bin \
+ ggml-base-q5_1.bin ggml-base-q8_0.bin ggml-base.bin \
+ ggml-tiny-q5_1.bin ggml-tiny-q8_0.bin ggml-tiny.bin; do
+ if [ -f "$dir/$candidate" ]; then
+ echo "$dir/$candidate"
+ return 0
+ fi
+ done
+ done
+ return 1
+}
+
+# Newest cookies.txt OmniGet holds for a domain (e.g. instagram.com), if any.
+og_cookie_file() {
+ local domain="$1" root dir
+ root="$(og_data_dir)/cookies"
+ [ -d "$root" ] || return 1
+ for dir in "$root"/*"$domain"*; do
+ [ -d "$dir" ] || continue
+ ls -t "$dir"/*.txt 2>/dev/null | head -n 1
+ return 0
+ done
+ return 1
+}
+
+# Load API keys from the environment or ~/.config/ai-keys.env. Never prints values.
+og_load_keys() {
+ local file="${OMNIGET_KEYS_FILE:-$HOME/.config/ai-keys.env}"
+ if [ -f "$file" ]; then
+ set -a
+ # shellcheck disable=SC1090
+ . "$file"
+ set +a
+ fi
+}
+
+og_has_key() {
+ og_load_keys
+ [ -n "$(eval "printf '%s' \"\${$1:-}\"")" ]
+}
+
+# og_json key=value key:n=number key:b=bool ... -> one JSON object on stdout. Empty values are omitted.
+og_json() {
+ python3 - "$@" <<'PY'
+import json, sys
+out = {}
+for kv in sys.argv[1:]:
+ key, _, value = kv.partition("=")
+ if value == "":
+ continue
+ name, _, kind = key.partition(":")
+ if kind == "n":
+ try:
+ out[name] = int(value)
+ except ValueError:
+ out[name] = float(value)
+ elif kind == "b":
+ out[name] = value.lower() in ("1", "true", "yes")
+ else:
+ out[name] = value
+print(json.dumps(out, ensure_ascii=False))
+PY
+}
+
+# og_slug TEXT -> filesystem-safe ASCII slug, max 80 chars.
+og_slug() {
+ python3 - "$1" <<'PY'
+import re, sys, unicodedata
+text = unicodedata.normalize("NFKD", sys.argv[1]).encode("ascii", "ignore").decode()
+text = re.sub(r"[^A-Za-z0-9]+", "_", text).strip("_")
+print((text or "untitled")[:80].rstrip("_"))
+PY
+}
+
+# og_url_host URL -> bare host without www./m. prefixes.
+og_url_host() {
+ printf '%s\n' "$1" | sed -E 's#^[A-Za-z]+://##; s#[/?].*##; s#^(www|m|mobile)\.##'
+}
+
+# og_cookie_args URL -> yt-dlp cookie flags for that host, if OmniGet or the user provides any.
+og_cookie_args() {
+ local host file
+ host="$(og_url_host "$1")"
+ case "$host" in
+ x.com) host=twitter.com ;;
+ esac
+ if file="$(og_cookie_file "$host")" && [ -n "$file" ]; then
+ printf -- '--cookies\n%s\n' "$file"
+ elif [ -n "${OMNIGET_COOKIES_FROM_BROWSER:-}" ]; then
+ printf -- '--cookies-from-browser\n%s\n' "$OMNIGET_COOKIES_FROM_BROWSER"
+ fi
+}
+
+og_is_url() {
+ case "$1" in
+ http://*|https://*) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
+# Hosts where omniget-cli's native extractors beat plain yt-dlp.
+og_prefers_cli() {
+ case "$(og_url_host "$1")" in
+ instagram.com|threads.net|threads.com|twitter.com|x.com|bilibili.com|b23.tv) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
+if [ "${BASH_SOURCE[0]}" = "$0" ]; then
+ tools="$*"
+ [ -n "$tools" ] || tools="omniget-cli yt-dlp ffmpeg ffprobe whisper-cli mlx_whisper"
+ for t in $tools; do
+ if found="$(og_find_tool "$t")"; then
+ printf '%s\t%s\n' "$t" "$found"
+ else
+ printf '%s\t-\tmissing\n' "$t"
+ fi
+ done
+fi
diff --git a/claude-plugin/omniget/scripts/srt_tools.py b/claude-plugin/omniget/scripts/srt_tools.py
new file mode 100755
index 00000000..c3665a6f
--- /dev/null
+++ b/claude-plugin/omniget/scripts/srt_tools.py
@@ -0,0 +1,241 @@
+#!/usr/bin/env python3
+"""SRT/VTT helpers for the omniget skill.
+
+Subcommands:
+ to-md <file> [--title T] [--source URL] [--backend B] [--model M] [--interval S]
+ to-text <file>
+ concat --out merged.srt part.srt:OFFSET_SECONDS ...
+ stats <file> -> JSON {cues, chars, duration}
+
+Standard library only, Python 3.8+.
+"""
+import argparse
+import html
+import json
+import re
+import sys
+from dataclasses import dataclass
+from typing import List, Tuple
+
+TS_RE = re.compile(r"(?:(\d+):)?(\d{1,2}):(\d{2})[.,](\d{1,3})")
+TAG_RE = re.compile(r"<[^>]+>")
+WS_RE = re.compile(r"\s+")
+
+
+@dataclass
+class Cue:
+ start: float
+ end: float
+ text: str
+
+
+def parse_ts(raw: str) -> float:
+ m = TS_RE.search(raw)
+ if not m:
+ raise ValueError("bad timestamp: %r" % raw)
+ hours = int(m.group(1) or 0)
+ ms = m.group(4).ljust(3, "0")
+ return hours * 3600 + int(m.group(2)) * 60 + int(m.group(3)) + int(ms) / 1000.0
+
+
+def clean_text(raw: str) -> str:
+ text = html.unescape(TAG_RE.sub("", raw))
+ return WS_RE.sub(" ", text).strip()
+
+
+def parse_cues(content: str) -> List[Cue]:
+ """Parse SRT or VTT into cues.
+
+ Boundary-based on the `-->` lines rather than blank-line blocks, so output
+ that omits blank separators between cues (as some models emit) still parses.
+ The lone integer index that precedes the next cue is stripped from a cue's
+ trailing text.
+ """
+ lines = content.replace("\r", "").split("\n")
+ ts_lines = [i for i, l in enumerate(lines) if "-->" in l]
+ cues: List[Cue] = []
+ for k, i in enumerate(ts_lines):
+ left, _, right = lines[i].partition("-->")
+ try:
+ start = parse_ts(left)
+ end = parse_ts(right.split()[0] if right.split() else right)
+ except ValueError:
+ continue
+ stop = ts_lines[k + 1] if k + 1 < len(ts_lines) else len(lines)
+ text_lines = lines[i + 1:stop]
+ while text_lines and not text_lines[-1].strip():
+ text_lines.pop()
+ if k + 1 < len(ts_lines) and text_lines and text_lines[-1].strip().isdigit():
+ text_lines.pop() # the next cue's index number, not caption text
+ cleaned = [clean_text(l) for l in text_lines]
+ cleaned = [c for c in cleaned if c]
+ if cleaned:
+ cues.append(Cue(start, end, "\n".join(cleaned)))
+ return cues
+
+def _merge_line(prev: str, line: str) -> Tuple[bool, str]:
+ """Collapse rolling captions. Returns (replace_previous, merged_text)."""
+ if line == prev:
+ return True, prev
+ if line.startswith(prev):
+ return True, line
+ pw = prev.split(" ")
+ lw = line.split(" ")
+ max_overlap = min(len(pw), len(lw)) - 1
+ for n in range(max_overlap, 1, -1):
+ if pw[-n:] == lw[:n]:
+ return True, " ".join(pw + lw[n:])
+ return False, line
+
+
+def dedupe(cues: List[Cue]) -> List[Tuple[float, str]]:
+ """Flatten cues into (start, line) pairs with rolling repeats removed."""
+ out: List[Tuple[float, str]] = []
+ for cue in cues:
+ for line in cue.text.split("\n"):
+ if out:
+ replace, merged = _merge_line(out[-1][1], line)
+ if replace:
+ out[-1] = (out[-1][0], merged)
+ continue
+ out.append((cue.start, line))
+ return out
+
+
+def to_text(cues: List[Cue]) -> str:
+ return " ".join(line for _, line in dedupe(cues))
+
+
+def fmt_marker(seconds: float) -> str:
+ total = int(seconds)
+ h, rem = divmod(total, 3600)
+ m, s = divmod(rem, 60)
+ if h:
+ return "%d:%02d:%02d" % (h, m, s)
+ return "%02d:%02d" % (m, s)
+
+
+def fmt_srt_ts(seconds: float) -> str:
+ total_ms = int(round(seconds * 1000))
+ h, rem = divmod(total_ms, 3600000)
+ m, rem = divmod(rem, 60000)
+ s, ms = divmod(rem, 1000)
+ return "%02d:%02d:%02d,%03d" % (h, m, s, ms)
+
+
+def to_markdown(cues: List[Cue], interval: float = 60.0) -> str:
+ paragraphs: List[str] = []
+ current: List[str] = []
+ para_start = None
+ for start, line in dedupe(cues):
+ if para_start is None:
+ para_start = start
+ elif start - para_start >= interval:
+ paragraphs.append("[%s] %s" % (fmt_marker(para_start), " ".join(current)))
+ current = []
+ para_start = start
+ current.append(line)
+ if current and para_start is not None:
+ paragraphs.append("[%s] %s" % (fmt_marker(para_start), " ".join(current)))
+ return "\n\n".join(paragraphs)
+
+
+def offset_cues(cues: List[Cue], seconds: float) -> List[Cue]:
+ return [Cue(c.start + seconds, c.end + seconds, c.text) for c in cues]
+
+
+def render_srt(cues: List[Cue]) -> str:
+ parts = []
+ for i, c in enumerate(cues, 1):
+ parts.append("%d\n%s --> %s\n%s\n" % (i, fmt_srt_ts(c.start), fmt_srt_ts(c.end), c.text))
+ return "\n".join(parts)
+
+
+def read(path: str) -> str:
+ with open(path, encoding="utf-8", errors="replace") as fh:
+ return fh.read()
+
+
+def cmd_to_md(args) -> int:
+ cues = parse_cues(read(args.file))
+ body = to_markdown(cues, args.interval)
+ header = []
+ if args.title:
+ header.append("# %s" % args.title)
+ header.append("")
+ meta = []
+ if args.source:
+ meta.append("- Source: %s" % args.source)
+ if args.backend:
+ engine = args.backend + (" (%s)" % args.model if args.model else "")
+ meta.append("- Transcribed with: %s" % engine)
+ if cues:
+ meta.append("- Duration: %s" % fmt_marker(cues[-1].end))
+ if meta:
+ header.extend(meta)
+ header.append("")
+ sys.stdout.write("\n".join(header) + body + "\n")
+ return 0
+
+
+def cmd_to_text(args) -> int:
+ sys.stdout.write(to_text(parse_cues(read(args.file))) + "\n")
+ return 0
+
+
+def cmd_concat(args) -> int:
+ merged: List[Cue] = []
+ for spec in args.parts:
+ path, _, offset = spec.rpartition(":")
+ if not path:
+ path, offset = spec, "0"
+ merged.extend(offset_cues(parse_cues(read(path)), float(offset)))
+ merged.sort(key=lambda c: c.start)
+ with open(args.out, "w", encoding="utf-8") as fh:
+ fh.write(render_srt(merged))
+ return 0
+
+
+def cmd_stats(args) -> int:
+ cues = parse_cues(read(args.file))
+ text = to_text(cues)
+ print(json.dumps({
+ "cues": len(cues),
+ "chars": len(text),
+ "duration": cues[-1].end if cues else 0.0,
+ }))
+ return 0
+
+
+def main(argv=None) -> int:
+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ sub = parser.add_subparsers(dest="cmd", required=True)
+
+ p = sub.add_parser("to-md")
+ p.add_argument("file")
+ p.add_argument("--title")
+ p.add_argument("--source")
+ p.add_argument("--backend")
+ p.add_argument("--model")
+ p.add_argument("--interval", type=float, default=60.0)
+ p.set_defaults(func=cmd_to_md)
+
+ p = sub.add_parser("to-text")
+ p.add_argument("file")
+ p.set_defaults(func=cmd_to_text)
+
+ p = sub.add_parser("concat")
+ p.add_argument("--out", required=True)
+ p.add_argument("parts", nargs="+", help="path.srt:offset_seconds")
+ p.set_defaults(func=cmd_concat)
+
+ p = sub.add_parser("stats")
+ p.add_argument("file")
+ p.set_defaults(func=cmd_stats)
+
+ args = parser.parse_args(argv)
+ return args.func(args)
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/claude-plugin/omniget/scripts/transcribe.sh b/claude-plugin/omniget/scripts/transcribe.sh
new file mode 100755
index 00000000..0782931c
--- /dev/null
+++ b/claude-plugin/omniget/scripts/transcribe.sh
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+# Produce a transcript for a media URL or local file. Prints one JSON line:
+# {transcript, srt?, backend, model?, title, duration?, chars, source}
+#
+# Ladder (backend=auto): platform captions -> whisper-cli (local) -> mlx_whisper (local, Apple Silicon)
+# -> Gemini (GEMINI_API_KEY) -> OpenAI (OPENAI_API_KEY)
+# Usage: transcribe.sh <url|file> [--backend auto|captions|local|mlx|gemini|openai]
+# [--model NAME] [--lang xx] [--out DIR] [--keep-audio] [--title T]
+set -eu
+set -o pipefail
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+. "$here/resolve-tools.sh"
+
+input=""; backend="auto"; model=""; lang=""; out=""; keep_audio=false; title=""
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --backend) backend="$2"; shift ;;
+ --model) model="$2"; shift ;;
+ --lang) lang="$2"; shift ;;
+ --out) out="$2"; shift ;;
+ --title) title="$2"; shift ;;
+ --keep-audio) keep_audio=true ;;
+ -*) echo "transcribe: unknown flag $1" >&2; exit 2 ;;
+ *) input="$1" ;;
+ esac
+ shift
+done
+[ -n "$input" ] || { echo "usage: transcribe.sh <url|file> [--backend B] [--model M] [--lang xx] [--out DIR]" >&2; exit 2; }
+case "$backend" in auto|captions|local|mlx|gemini|openai) ;; *) echo "transcribe: bad --backend $backend" >&2; exit 2 ;; esac
+[ -n "$out" ] || out="$(og_output_dir)/transcripts"
+mkdir -p "$out"
+
+tmp="$(mktemp -d "${TMPDIR:-/tmp}/omniget-transcribe.XXXXXX")"
+trap 'rm -rf "$tmp"' EXIT
+log() { echo "transcribe: $*" >&2; }
+
+id=""; duration=""; source="$input"; audio=""
+if og_is_url "$input"; then
+ ytdlp="$(og_tool_path yt-dlp)" || { log "yt-dlp not found; run doctor.sh"; exit 1; }
+ cookie_args=()
+ while IFS= read -r line; do cookie_args+=("$line"); done < <(og_cookie_args "$input")
+
+ # One yt-dlp call fetches metadata and any captions. --print implies --skip-download.
+ sub_langs="en.*,en,.*-orig"
+ [ -n "$lang" ] && sub_langs="$lang.*,$lang,$sub_langs"
+ meta="$("$ytdlp" --no-warnings --no-playlist --write-subs --write-auto-subs \
+ --sub-langs "$sub_langs" --convert-subs srt -o "$tmp/cap.%(ext)s" \
+ --print "%(id)s ||| %(duration)s ||| %(title)s" ${cookie_args[@]+${cookie_args[@]+"${cookie_args[@]}"}} "$input" | head -n 1)"
+ id="$(printf '%s' "$meta" | awk -F' \\|\\|\\| ' '{print $1}')"
+ duration="$(printf '%s' "$meta" | awk -F' \\|\\|\\| ' '{print $2}')"
+ [ -n "$title" ] || title="$(printf '%s' "$meta" | awk -F' \\|\\|\\| ' '{print $3}')"
+ [ "$duration" = "NA" ] && duration=""
+
+ caption=""
+ if [ "$backend" = auto ] || [ "$backend" = captions ]; then
+ caption="$(ls -S "$tmp"/cap.*.srt "$tmp"/cap.*.vtt 2>/dev/null | head -n 1 || true)"
+ if [ -z "$caption" ]; then
+ "$ytdlp" --no-warnings --no-playlist --skip-download --write-subs --sub-langs all \
+ --convert-subs srt -o "$tmp/cap.%(ext)s" ${cookie_args[@]+${cookie_args[@]+"${cookie_args[@]}"}} "$input" >/dev/null 2>&1 || true
+ caption="$(ls -S "$tmp"/cap.*.srt "$tmp"/cap.*.vtt 2>/dev/null | head -n 1 || true)"
+ fi
+ fi
+ if [ -n "$caption" ] && [ "$(python3 "$here/srt_tools.py" stats "$caption" | python3 -c 'import json,sys; print(json.load(sys.stdin)["chars"])')" -gt 20 ]; then
+ srt_src="$caption"; used="captions"; used_model="$(basename "$caption" | sed 's/^cap\.//; s/\.[a-z]*$//')"
+ else
+ [ "$backend" = captions ] && { log "no usable captions for $input"; exit 3; }
+ log "no captions; downloading audio"
+ audio="$("$ytdlp" --no-warnings --no-playlist --no-simulate --quiet -f "bestaudio/best" \
+ -o "$tmp/audio.%(ext)s" --print "after_move:filepath" ${cookie_args[@]+${cookie_args[@]+"${cookie_args[@]}"}} "$input" | tail -n 1)"
+ fi
+else
+ [ -f "$input" ] || { log "no such file: $input"; exit 1; }
+ audio="$input"
+ [ -n "$title" ] || title="$(basename "${input%.*}")"
+ source="$(cd "$(dirname "$input")" && pwd)/$(basename "$input")"
+ [ "$backend" = captions ] && { log "--backend captions needs a URL"; exit 2; }
+fi
+
+if [ -n "$audio" ]; then
+ ffmpeg="$(og_tool_path ffmpeg)" || { log "ffmpeg not found; run doctor.sh"; exit 1; }
+ if [ -z "$duration" ] && ffprobe="$(og_tool_path ffprobe)"; then
+ duration="$("$ffprobe" -v error -show_entries format=duration -of csv=p=0 "$audio" 2>/dev/null || true)"
+ fi
+
+ if [ "$backend" = auto ]; then
+ if og_find_tool whisper-cli >/dev/null && og_whisper_model >/dev/null; then backend=local
+ elif og_find_tool mlx_whisper >/dev/null; then backend=mlx
+ elif og_has_key GEMINI_API_KEY; then backend=gemini
+ elif og_has_key OPENAI_API_KEY; then backend=openai
+ else
+ log "no transcription backend available: install whisper-cli + a model, mlx-whisper, or set GEMINI_API_KEY / OPENAI_API_KEY (see doctor.sh)"
+ exit 4
+ fi
+ fi
+ log "backend: $backend"
+
+ case "$backend" in
+ local)
+ cli="$(og_tool_path whisper-cli)" || { log "whisper-cli not found (brew install whisper-cpp)"; exit 4; }
+ if [ -n "$model" ]; then
+ [ -f "$model" ] || model="$("$here/get-model.sh" "$model")"
+ else
+ model="$(og_whisper_model)" || { log "no whisper model; run get-model.sh large-v3-turbo-q5_0"; exit 4; }
+ fi
+ "$ffmpeg" -v error -y -i "$audio" -ac 1 -ar 16000 -c:a pcm_s16le "$tmp/a16.wav"
+ threads="$( (sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4) )"
+ [ "$threads" -gt 8 ] && threads=8
+ "$cli" -m "$model" -f "$tmp/a16.wav" -l "${lang:-auto}" -t "$threads" -osrt -of "$tmp/out" -np -pp 1>&2
+ srt_src="$tmp/out.srt"; used=local; used_model="$(basename "$model")"
+ ;;
+ mlx)
+ mlx="$(og_tool_path mlx_whisper)" || { log "mlx_whisper not found (uv tool install mlx-whisper)"; exit 4; }
+ [ -n "$model" ] || model="mlx-community/whisper-large-v3-turbo"
+ "$ffmpeg" -v error -y -i "$audio" -ac 1 -ar 16000 -c:a pcm_s16le "$tmp/a16.wav"
+ "$mlx" "$tmp/a16.wav" --model "$model" --output-dir "$tmp" --output-name out --output-format srt \
+ ${lang:+--language "$lang"} 1>&2
+ srt_src="$tmp/out.srt"; used=mlx; used_model="$model"
+ ;;
+ gemini)
+ og_load_keys
+ [ -n "$model" ] || model="gemini-2.5-flash"
+ "$ffmpeg" -v error -y -i "$audio" -ac 1 -ar 16000 -b:a 32k "$tmp/a16.mp3"
+ result="$(python3 "$here/gemini_transcribe.py" "$tmp/a16.mp3" --out "$tmp/out.srt" --model "$model" ${lang:+--lang "$lang"})"
+ used=gemini; used_model="$model"
+ case "$result" in *.srt) srt_src="$result" ;; *) text_src="$result" ;; esac
+ ;;
+ openai)
+ og_load_keys
+ [ -n "$model" ] || model="whisper-1"
+ "$ffmpeg" -v error -y -i "$audio" -ac 1 -ar 16000 -b:a 32k "$tmp/a16.mp3"
+ result="$("$here/openai_transcribe.sh" "$tmp/a16.mp3" --out "$tmp/out.srt" --model "$model" ${lang:+--lang "$lang"})"
+ used=openai; used_model="$model"
+ case "$result" in *.srt) srt_src="$result" ;; *) text_src="$result" ;; esac
+ ;;
+ esac
+fi
+
+slug="$(og_slug "$title")"
+[ -n "$id" ] && slug="$slug-$id"
+md="$out/$slug.md"
+srt=""
+if [ -n "${srt_src:-}" ]; then
+ srt="$out/$slug.srt"
+ cp "$srt_src" "$srt"
+ python3 "$here/srt_tools.py" to-md "$srt" --title "$title" --source "$source" --backend "$used" --model "$used_model" > "$md"
+else
+ {
+ printf '# %s\n\n- Source: %s\n- Transcribed with: %s (%s)\n\n' "$title" "$source" "$used" "$used_model"
+ cat "$text_src"
+ } > "$md"
+fi
+
+kept=""
+if $keep_audio && [ -n "$audio" ] && og_is_url "$input"; then
+ kept="$out/$slug.${audio##*.}"
+ cp "$audio" "$kept"
+fi
+
+chars="$(python3 -c 'import sys; print(len(open(sys.argv[1], encoding="utf-8").read()))' "$md")"
+og_json transcript="$md" srt="$srt" backend="$used" model="$used_model" title="$title" duration:n="$duration" chars:n="$chars" source="$source" audio="$kept"
diff --git a/claude-plugin/omniget/skills/omniget-fetch/SKILL.md b/claude-plugin/omniget/skills/omniget-fetch/SKILL.md
new file mode 100644
index 00000000..4c2ff5a6
--- /dev/null
+++ b/claude-plugin/omniget/skills/omniget-fetch/SKILL.md
@@ -0,0 +1,60 @@
+---
+name: omniget-fetch
+description: This skill should be used when the user pastes a video, audio or social-post URL (YouTube, TikTok, Instagram, X/Twitter, Reddit, Vimeo, Twitch, Bilibili, Threads, Pinterest, direct .mp4/.m3u8 links) and asks to "download this", "get this video", "save the audio", "grab this reel", "fetch this clip", "pull the mp4", or otherwise wants the media file on disk. Also covers "what tools do I have for downloading" and "why did the download fail".
+version: 0.1.0
+---
+
+# Fetching media with OmniGet's tooling
+
+Download media through the plugin's scripts instead of hand-writing yt-dlp
+invocations. The scripts reuse whatever the user already has, in this order:
+`omniget-cli` on PATH, the binaries OmniGet manages inside its app-data folder,
+then system `yt-dlp`/`ffmpeg`. Every script prints one JSON line on success.
+
+Scripts live in `${CLAUDE_PLUGIN_ROOT}/scripts/`.
+
+## Workflow
+
+1. Run the download. Quote the URL.
+ ```bash
+ bash "${CLAUDE_PLUGIN_ROOT}/scripts/fetch.sh" "<url>" [--audio] [--quality 720] [--out DIR]
+ ```
+ Output: `{"file","title","duration","size","platform","engine","id"}`.
+ - Default output directory is `~/Downloads/omniget` (override with `OMNIGET_DIR` or `--out`).
+ - `--audio` keeps only the audio track as `.m4a`. `--quality N` caps the video height.
+ - Instagram, Threads, X and Bilibili links go through `omniget-cli` when it is installed,
+ which brings OmniGet's native extractors and cookie accounts.
+2. Report the file path, size and duration in one or two sentences. Do not paste the JSON.
+3. If the user only wants to know what the media says, use the `omniget-transcribe` skill
+ instead of downloading video.
+
+## When something fails
+
+Run the doctor first, then act on what it reports:
+```bash
+bash "${CLAUDE_PLUGIN_ROOT}/scripts/doctor.sh"
+```
+
+| Symptom in stderr | Meaning | Action |
+|---|---|---|
+| `yt-dlp not found` | no engine available | show the doctor's install lines and ask before installing anything |
+| `Sign in to confirm`, `login required`, `Private video`, HTTP 401/403 | platform wants a session | use OmniGet's cookies (automatic when the app has an account for that site) or set `OMNIGET_COOKIES_FROM_BROWSER=chrome` and retry |
+| HTTP 429, `rate-limit` | too many requests | wait 30 s and retry once; then stop and tell the user |
+| `DRM`, `SAMPLE-AES`, `Widevine` | protected stream | stop; explain that OmniGet does not bypass DRM |
+| `Unsupported URL` | no extractor | say so; suggest the page's direct media link if the user has one |
+| `Requested format is not available` | quality cap too strict | retry without `--quality` |
+
+## Rules
+
+- Downloads happen only when the user asked for the media. A bare URL with a question
+ about its content is a transcription request, not a download request.
+- Never run an install command (brew, winget, apt, pip, uv) without the user's explicit yes;
+ the doctor prints the commands, the user decides.
+- Cookies files and API keys are never printed, copied or committed.
+- Prefer `--audio` for podcasts, talks and anything the user will only listen to or transcribe.
+
+## Environment variables
+
+`OMNIGET_DIR` (output), `OMNIGET_DATA_DIR` (OmniGet app data, auto-detected per OS),
+`OMNIGET_TOOL_YT_DLP` / `OMNIGET_TOOL_FFMPEG` (explicit binaries),
+`OMNIGET_COOKIES_FROM_BROWSER` (chrome, firefox, safari, edge).
diff --git a/claude-plugin/omniget/skills/omniget-transcribe/SKILL.md b/claude-plugin/omniget/skills/omniget-transcribe/SKILL.md
new file mode 100644
index 00000000..bd7d7596
--- /dev/null
+++ b/claude-plugin/omniget/skills/omniget-transcribe/SKILL.md
@@ -0,0 +1,62 @@
+---
+name: omniget-transcribe
+description: This skill should be used when the user shares a video, audio, podcast or social-post URL or a local media file and asks "what does this video say", "transcribe this", "summarize this video", "get the transcript", "what is this reel about", "research this post", "pull the caption", "turn this talk into notes", "quote the part where", "translate what they say", or wants to analyze spoken content from a link. Covers YouTube, TikTok, Instagram, X/Twitter, Reddit, Vimeo, Twitch, Bilibili, Threads and any local .mp4/.mp3/.wav/.m4a.
+version: 0.1.0
+---
+
+# Transcribing and researching media
+
+Turn a link or file into text with `${CLAUDE_PLUGIN_ROOT}/scripts/`, then read the
+transcript and answer. Claude cannot hear audio, so a speech-to-text step always runs first.
+Each script prints one JSON line on success; progress goes to stderr.
+
+## Pipeline
+
+1. **Describe the source** (URL only, no download):
+ ```bash
+ bash "${CLAUDE_PLUGIN_ROOT}/scripts/research.sh" "<url>"
+ ```
+ Returns `title`, `platform`, `uploader`, `duration`, `has_captions`, and `caption`
+ (the post text or description) when the platform provides one. Skip this step for local files.
+2. **Get the transcript**:
+ ```bash
+ bash "${CLAUDE_PLUGIN_ROOT}/scripts/transcribe.sh" "<url-or-file>" [--backend auto|captions|local|mlx|gemini|openai] [--model NAME] [--lang xx] [--out DIR]
+ ```
+ Returns `transcript` (Markdown with `[mm:ss]` markers), `srt` when timestamps exist,
+ `backend`, `model`, `duration`, `chars`. Files land in `~/Downloads/omniget/transcripts`
+ unless `--out` or `OMNIGET_DIR` says otherwise.
+3. **Read the `.md` file** and do what was asked: summarize, extract key points, quote with
+ timestamps, translate, or write a research note that combines the caption and the transcript.
+ Cite moments as `[mm:ss]`. Do not paste the whole transcript back unless asked.
+
+## Backend ladder (`--backend auto`)
+
+| Order | Backend | Needs | Cost | Notes |
+|---|---|---|---|---|
+| 1 | `captions` | platform subtitles | free, seconds | tried first for every URL; auto-captions are rough but usable |
+| 2 | `local` | `whisper-cli` + a ggml model | free, private | CPU/Metal; `large-v3-turbo-q5_0` is the default model choice |
+| 3 | `mlx` | `mlx_whisper` (Apple Silicon) | free, private | faster than whisper-cli on M-series Macs |
+| 4 | `gemini` | `GEMINI_API_KEY` | cents per hour | audio-native; good for long recordings |
+| 5 | `openai` | `OPENAI_API_KEY` | about $0.006 per minute | `whisper-1` returns timestamps; `--model gpt-4o-transcribe` is more accurate but text-only |
+
+Choose deliberately when the user states a preference:
+- "most accurate" with an OpenAI key: `--backend openai --model gpt-4o-transcribe`.
+- "free" or "offline" or "private": `--backend local` (or `mlx` on a Mac).
+- Known language: pass `--lang en` (or `pt`, `es`, ...) to every backend; it speeds up and sharpens results.
+- Recording longer than two hours: say so and confirm before a cloud backend runs.
+
+Keys are read from the environment or `~/.config/ai-keys.env`. Never print them.
+
+## Exit codes and what to do
+
+| Exit | Meaning | Action |
+|---|---|---|
+| 3 | `--backend captions` and the platform has none | rerun with `--backend auto` |
+| 4 | no local engine and no key | run `doctor.sh`, show the install lines, ask before installing; `get-model.sh large-v3-turbo-q5_0` fetches the model (547 MB) |
+| 1 | tool missing or download failed | run `doctor.sh`; for login errors see the `omniget-fetch` skill's error table |
+
+## Rules
+
+- Never start an install or a model download without the user's explicit yes.
+- Summaries state which backend produced the transcript when accuracy matters (auto-captions vs. Whisper).
+- Keep `.srt` and `.md` next to each other; the user may open the SRT in OmniGet's Subtitle Workshop.
diff --git a/claude-plugin/omniget/tests/test_gemini_norm.py b/claude-plugin/omniget/tests/test_gemini_norm.py
new file mode 100644
index 00000000..e3f874ad
--- /dev/null
+++ b/claude-plugin/omniget/tests/test_gemini_norm.py
@@ -0,0 +1,44 @@
+import importlib.util
+import os
+import sys
+import unittest
+
+HERE = os.path.dirname(__file__)
+SCRIPTS = os.path.join(HERE, "..", "scripts")
+sys.path.insert(0, SCRIPTS)
+
+import srt_tools # noqa: E402
+
+spec = importlib.util.spec_from_file_location("gemini_transcribe", os.path.join(SCRIPTS, "gemini_transcribe.py"))
+gemini = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(gemini)
+
+
+class NormalizeTests(unittest.TestCase):
+ def _first(self, raw):
+ cues = srt_tools.parse_cues(gemini.normalize_srt_timestamps(raw))
+ self.assertTrue(cues, "no cue parsed from %r" % raw)
+ return srt_tools.fmt_srt_ts(cues[0].start), srt_tools.fmt_srt_ts(cues[0].end)
+
+ def test_mm_ss_ms_with_colon(self):
+ self.assertEqual(self._first("1\n00:17:200 --> 00:18:400\nx\n"), ("00:00:17,200", "00:00:18,400"))
+
+ def test_dot_millis(self):
+ self.assertEqual(self._first("1\n00:00:01.500 --> 00:00:03.000\nx\n"), ("00:00:01,500", "00:00:03,000"))
+
+ def test_no_millis_hms(self):
+ self.assertEqual(self._first("1\n01:02:03 --> 01:02:05\nx\n"), ("01:02:03,000", "01:02:05,000"))
+
+ def test_bare_mm_ss(self):
+ self.assertEqual(self._first("1\n00:05 --> 00:09\nx\n"), ("00:00:05,000", "00:00:09,000"))
+
+ def test_correct_form_untouched(self):
+ self.assertEqual(self._first("1\n00:00:17,200 --> 00:00:18,400\nx\n"), ("00:00:17,200", "00:00:18,400"))
+
+ def test_non_timestamp_lines_survive(self):
+ raw = "WEBVTT stays\n1\n00:00:01,000 --> 00:00:02,000\nhello\n"
+ self.assertIn("hello", gemini.normalize_srt_timestamps(raw))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/claude-plugin/omniget/tests/test_srt_tools.py b/claude-plugin/omniget/tests/test_srt_tools.py
new file mode 100644
index 00000000..6377593f
--- /dev/null
+++ b/claude-plugin/omniget/tests/test_srt_tools.py
@@ -0,0 +1,110 @@
+import os
+import sys
+import unittest
+
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts"))
+
+import srt_tools # noqa: E402
+
+SRT = """1
+00:00:00,000 --> 00:00:02,500
+Hello <b>world</b> &amp; friends
+
+2
+00:00:02,500 --> 00:00:05,000
+second line
+"""
+
+VTT = """WEBVTT
+Kind: captions
+Language: en
+
+00:00:00.000 --> 00:00:02.500 align:start position:0%
+Hello world
+
+00:00:02.500 --> 00:00:05.000
+second line
+"""
+
+ROLLING = """1
+00:00:00,000 --> 00:00:01,000
+Hello world
+
+2
+00:00:01,000 --> 00:00:02,000
+Hello world this is
+
+3
+00:00:02,000 --> 00:00:03,000
+this is a test
+"""
+
+
+class ParseTests(unittest.TestCase):
+ def test_parses_srt_and_strips_markup(self):
+ cues = srt_tools.parse_cues(SRT)
+ self.assertEqual(len(cues), 2)
+ self.assertEqual(cues[0].start, 0.0)
+ self.assertEqual(cues[0].end, 2.5)
+ self.assertEqual(cues[0].text, "Hello world & friends")
+ self.assertEqual(cues[1].text, "second line")
+
+ def test_parses_vtt_with_cue_settings(self):
+ cues = srt_tools.parse_cues(VTT)
+ self.assertEqual(len(cues), 2)
+ self.assertEqual(cues[0].text, "Hello world")
+ self.assertEqual(cues[1].start, 2.5)
+
+ def test_hours_are_parsed(self):
+ cues = srt_tools.parse_cues("1\n01:02:03,004 --> 01:02:04,000\nx\n")
+ self.assertAlmostEqual(cues[0].start, 3723.004)
+
+
+ def test_parses_cues_without_blank_separators(self):
+ # Some models emit consecutive cues with no blank line between blocks.
+ raw = ("1\n00:00:00,000 --> 00:00:02,000\nfirst line\n"
+ "2\n00:00:02,000 --> 00:00:04,000\nsecond line\n")
+ cues = srt_tools.parse_cues(raw)
+ self.assertEqual(len(cues), 2)
+ self.assertEqual(cues[0].text, "first line")
+ self.assertEqual(cues[1].text, "second line")
+
+ def test_final_numeric_caption_is_kept(self):
+ raw = "1\n00:00:01,000 --> 00:00:02,000\n2024\n"
+ cues = srt_tools.parse_cues(raw)
+ self.assertEqual(cues[0].text, "2024")
+
+
+class TranscriptTests(unittest.TestCase):
+ def test_rolling_captions_are_deduplicated(self):
+ cues = srt_tools.parse_cues(ROLLING)
+ self.assertEqual(srt_tools.to_text(cues), "Hello world this is a test")
+
+ def test_markdown_has_time_markers_per_interval(self):
+ cues = [
+ srt_tools.Cue(0.0, 2.0, "one"),
+ srt_tools.Cue(30.0, 32.0, "two"),
+ srt_tools.Cue(70.0, 72.0, "three"),
+ ]
+ md = srt_tools.to_markdown(cues, interval=60)
+ self.assertIn("[00:00] one two", md)
+ self.assertIn("[01:10] three", md)
+
+ def test_markdown_marker_uses_hours_when_needed(self):
+ cues = [srt_tools.Cue(3725.0, 3726.0, "late")]
+ self.assertIn("[1:02:05] late", srt_tools.to_markdown(cues, interval=60))
+
+
+class ConcatTests(unittest.TestCase):
+ def test_offset_and_render_round_trip(self):
+ cues = srt_tools.parse_cues(SRT)
+ shifted = srt_tools.offset_cues(cues, 1200.0)
+ srt = srt_tools.render_srt(shifted)
+ again = srt_tools.parse_cues(srt)
+ self.assertEqual(again[0].start, 1200.0)
+ self.assertEqual(again[1].end, 1205.0)
+ self.assertIn("00:20:00,000 --> 00:20:02,500", srt)
+
+
+if __name__ == "__main__":
+ unittest.main()