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): auto-retry blocked downloads with the browser login

Theodore Imonigie35ca8e4aae54
diff --git a/claude-plugin/omniget/.claude-plugin/plugin.json b/claude-plugin/omniget/.claude-plugin/plugin.json
index 7d19e932..3f988651 100644
--- a/claude-plugin/omniget/.claude-plugin/plugin.json
+++ b/claude-plugin/omniget/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "omniget",
- "version": "0.3.0",
+ "version": "0.4.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"
diff --git a/claude-plugin/omniget/INSTALL.md b/claude-plugin/omniget/INSTALL.md
index 9bc1c55a..0ded59e5 100644
--- a/claude-plugin/omniget/INSTALL.md
+++ b/claude-plugin/omniget/INSTALL.md
@@ -96,10 +96,11 @@ behind login, and even OmniGet depends on a signed-in session for much of it. If
returns *"empty media response"* or *HTTP 400/429*:
- It's usually a **temporary rate-limit** — wait a few minutes and retry.
-- If the post is **private or login-gated**, provide a session: log into the site in the
- OmniGet app (its cookies are reused automatically), or set
- `OMNIGET_COOKIES_FROM_BROWSER=chrome` (or `firefox`/`safari`/`edge`) and retry. If your
- browser has multiple profiles, point at the right one, e.g. `chrome:Default`.
+- If the post is **private or login-gated**, the skill **retries automatically** using the
+ browser you're logged into (auto-detected). On macOS the first such read raises a one-time
+ Keychain prompt — allow it. If your browser has several profiles and the default isn't the
+ logged-in one, pin it: `OMNIGET_COOKIES_FROM_BROWSER=chrome:"Profile 3"`. Logging into the
+ site in the OmniGet app also works — those cookies are reused first, before any browser.
Public content on YouTube, TikTok, Reddit, Vimeo, Twitch, and the ~1,800 yt-dlp sites is
reliable and needs none of this.
diff --git a/claude-plugin/omniget/scripts/fetch.sh b/claude-plugin/omniget/scripts/fetch.sh
index c478d6fe..0cd0454a 100755
--- a/claude-plugin/omniget/scripts/fetch.sh
+++ b/claude-plugin/omniget/scripts/fetch.sh
@@ -60,10 +60,9 @@ elif [ -n "$quality" ]; then
else
args+=(-f "bv*+ba/b" --merge-output-format mp4)
fi
-while IFS= read -r line; do args+=("$line"); done < <(og_cookie_args "$url")
-
+# og_run_ytdlp adds cookies and does one browser-login retry if the site blocks us.
err="$(mktemp "${TMPDIR:-/tmp}/omniget-fetch.XXXXXX")"
-if ! output="$("$ytdlp" "${args[@]}" "$url" 2>"$err")"; then
+if ! output="$(og_run_ytdlp "$url" "$err" "${args[@]}")"; then
cat "$err" >&2
hint="$(og_explain_error "$(cat "$err" 2>/dev/null)")"
[ -n "$hint" ] && echo "-> $hint" >&2
diff --git a/claude-plugin/omniget/scripts/research.sh b/claude-plugin/omniget/scripts/research.sh
index 6e8f7d15..1a858e1e 100755
--- a/claude-plugin/omniget/scripts/research.sh
+++ b/claude-plugin/omniget/scripts/research.sh
@@ -11,9 +11,16 @@ here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
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 '
+err="$(mktemp "${TMPDIR:-/tmp}/omniget-research.XXXXXX")"
+if ! json="$(og_run_ytdlp "$url" "$err" "${args[@]}")"; then
+ cat "$err" >&2
+ hint="$(og_explain_error "$(cat "$err" 2>/dev/null)")"; [ -n "$hint" ] && echo "-> $hint" >&2
+ rm -f "$err"; exit 1
+fi
+rm -f "$err"
+
+printf '%s' "$json" | python3 -c '
import json, sys
info = json.load(sys.stdin)
if info.get("_type") == "playlist":
diff --git a/claude-plugin/omniget/scripts/resolve-tools.sh b/claude-plugin/omniget/scripts/resolve-tools.sh
index 78d0a9b7..31e0eb6b 100755
--- a/claude-plugin/omniget/scripts/resolve-tools.sh
+++ b/claude-plugin/omniget/scripts/resolve-tools.sh
@@ -238,6 +238,64 @@ og_explain_error() {
esac
}
+# og_detect_browser -> a browser name yt-dlp's --cookies-from-browser accepts, chosen from
+# what's installed (chrome, brave, edge, firefox, safari, chromium). Empty if none found.
+# Order favours the most commonly logged-in browser.
+og_detect_browser() {
+ case "$(og_os)" in
+ mac)
+ [ -d "/Applications/Google Chrome.app" ] && { echo chrome; return; }
+ [ -d "/Applications/Brave Browser.app" ] && { echo brave; return; }
+ [ -d "/Applications/Microsoft Edge.app" ] && { echo edge; return; }
+ [ -d "/Applications/Firefox.app" ] && { echo firefox; return; }
+ [ -d "/Applications/Safari.app" ] && { echo safari; return; }
+ ;;
+ linux)
+ for c in google-chrome google-chrome-stable brave-browser microsoft-edge firefox chromium chromium-browser; do
+ if command -v "$c" >/dev/null 2>&1; then
+ case "$c" in google-chrome*) echo chrome ;; brave*) echo brave ;; microsoft-edge) echo edge ;; firefox) echo firefox ;; chromium*) echo chromium ;; esac
+ return
+ fi
+ done
+ ;;
+ windows) echo chrome; return ;;
+ esac
+ return 1
+}
+
+# og_should_retry_with_cookies <stderr text> -> true when the failure is the login /
+# rate-limit class, i.e. a logged-in session is worth trying. Reuses og_explain_error's
+# categories without duplicating the patterns.
+og_should_retry_with_cookies() {
+ case "$(og_explain_error "$1")" in
+ "This platform is rate-limiting"*|"This content needs a logged-in session"*) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
+# og_run_ytdlp URL ERRFILE ARG... -> run yt-dlp ARG... URL, with ONE automatic cookie
+# retry if the first attempt is blocked and no cookies were used yet. Prints yt-dlp's
+# stdout on success; returns its exit code; stderr is captured to ERRFILE. When the retry
+# runs it prints a one-line notice to fd 2 (a browser-cookie read can raise a one-time
+# macOS Keychain prompt).
+og_run_ytdlp() {
+ local url="$1" errfile="$2"; shift 2
+ local ytdlp; ytdlp="$(og_tool_path yt-dlp)" || { echo "yt-dlp not found; run setup.sh" >"$errfile"; return 127; }
+ local cookie=() line had=false out br
+ while IFS= read -r line; do cookie+=("$line"); done < <(og_cookie_args "$url")
+ [ ${#cookie[@]} -gt 0 ] && had=true
+ if out="$("$ytdlp" "$@" ${cookie[@]+"${cookie[@]}"} "$url" 2>"$errfile")"; then
+ printf '%s' "$out"; return 0
+ fi
+ if ! $had && og_should_retry_with_cookies "$(cat "$errfile" 2>/dev/null)" && br="$(og_detect_browser)"; then
+ echo "omniget: request blocked — retrying with your $br login (a one-time Keychain prompt may appear)…" >&2
+ if out="$("$ytdlp" "$@" --cookies-from-browser "$br" "$url" 2>"$errfile")"; then
+ printf '%s' "$out"; return 0
+ fi
+ fi
+ return 1
+}
+
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
tools="$*"
[ -n "$tools" ] || tools="omniget-cli yt-dlp ffmpeg ffprobe whisper-cli mlx_whisper"
diff --git a/claude-plugin/omniget/scripts/transcribe.sh b/claude-plugin/omniget/scripts/transcribe.sh
index 55c1f4b5..fc83db0e 100755
--- a/claude-plugin/omniget/scripts/transcribe.sh
+++ b/claude-plugin/omniget/scripts/transcribe.sh
@@ -44,9 +44,9 @@ if og_is_url "$input"; then
sub_langs="en.*,en,.*-orig"
[ -n "$lang" ] && sub_langs="$lang.*,$lang,$sub_langs"
caperr="$tmp/yt.err"
- meta="$("$ytdlp" --no-warnings --no-playlist --write-subs --write-auto-subs \
+ meta="$(og_run_ytdlp "$input" "$caperr" --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[@]}"} "$input" 2>"$caperr" | head -n 1)"
+ --print "%(id)s ||| %(duration)s ||| %(title)s" | head -n 1)"
if [ -z "$meta" ] && grep -qiE "ERROR|empty media|HTTP Error" "$caperr" 2>/dev/null; then
cat "$caperr" >&2
hint="$(og_explain_error "$(cat "$caperr")")"; [ -n "$hint" ] && log "-> $hint"
@@ -62,7 +62,7 @@ if og_is_url "$input"; 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
+ --convert-subs srt -o "$tmp/cap.%(ext)s" ${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
@@ -71,8 +71,15 @@ if og_is_url "$input"; then
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)"
+ auderr="$tmp/audio.err"
+ audio="$(og_run_ytdlp "$input" "$auderr" --no-warnings --no-playlist --no-simulate --quiet -f "bestaudio/best" \
+ -o "$tmp/audio.%(ext)s" --print "after_move:filepath" | tail -n 1)"
+ if [ -z "$audio" ]; then
+ cat "$auderr" >&2 2>/dev/null || true
+ hint="$(og_explain_error "$(cat "$auderr" 2>/dev/null)")"; [ -n "$hint" ] && log "-> $hint"
+ log "could not download audio for $input"
+ exit 1
+ fi
fi
else
[ -f "$input" ] || { log "no such file: $input"; exit 1; }
diff --git a/claude-plugin/omniget/skills/omniget-fetch/SKILL.md b/claude-plugin/omniget/skills/omniget-fetch/SKILL.md
index 93b79208..d1b9079c 100644
--- a/claude-plugin/omniget/skills/omniget-fetch/SKILL.md
+++ b/claude-plugin/omniget/skills/omniget-fetch/SKILL.md
@@ -59,6 +59,8 @@ bash "${CLAUDE_PLUGIN_ROOT}/scripts/doctor.sh" --check-keys
On failure the scripts print a plain-language `-> hint` line classifying the cause (rate-limit / login / DRM). If a site that used to work now fails for everyone, the fix is usually stale tools: `bash "${CLAUDE_PLUGIN_ROOT}/scripts/setup.sh" --update`.
+**Automatic login retry.** When a fetch is blocked by a login wall or rate-limit, the scripts retry once on their own using the browser you're logged into (auto-detected: Chrome/Brave/Edge/Firefox/Safari). No flag needed. Two things to know: on macOS the first browser-cookie read raises a one-time Keychain prompt (allow it, or choose Always Allow); and if your browser has several profiles and the default one isn't logged in, pin the right one — `OMNIGET_COOKIES_FROM_BROWSER=chrome:"Profile 3"`. If it's still blocked after the retry, it's a hard rate-limit — wait a few minutes.
+
## Rules
- Downloads happen only when the user asked for the media. A bare URL with a question
diff --git a/claude-plugin/omniget/tests/test_retry.sh b/claude-plugin/omniget/tests/test_retry.sh
new file mode 100755
index 00000000..ffa3a794
--- /dev/null
+++ b/claude-plugin/omniget/tests/test_retry.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+# Tests og_run_ytdlp's one-shot cookie retry using a stub yt-dlp, so no network is needed.
+set -u
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+fail=0
+check() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 — expected [$3] got [$2]"; fail=1; fi; }
+
+tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
+
+# stub yt-dlp: fails with a rate-limit error unless --cookies-from-browser is passed.
+cat > "$tmp/yt-dlp" <<'STUB'
+#!/usr/bin/env bash
+for a in "$@"; do [ "$a" = "--cookies-from-browser" ] && { echo "OK title ||| 12 ||| Some Title"; exit 0; }; done
+echo "ERROR: Instagram sent an empty media response" >&2
+exit 1
+STUB
+chmod +x "$tmp/yt-dlp"
+
+# stub that always fails (even with cookies) -> block persists.
+cat > "$tmp/yt-dlp-hardfail" <<'STUB'
+#!/usr/bin/env bash
+echo "ERROR: Instagram sent an empty media response" >&2
+exit 1
+STUB
+chmod +x "$tmp/yt-dlp-hardfail"
+
+# stub that fails with a NON-retryable error (DRM) -> must NOT retry.
+cat > "$tmp/yt-dlp-drm" <<'STUB'
+#!/usr/bin/env bash
+echo "ERROR: HLS uses SAMPLE-AES (FairPlay DRM), cannot decrypt" >&2
+exit 1
+STUB
+chmod +x "$tmp/yt-dlp-drm"
+
+export OMNIGET_KEYS_FILE="$tmp/none.env" # keep key loading inert
+# shellcheck source=../scripts/resolve-tools.sh
+. "$here/../scripts/resolve-tools.sh"
+
+url="https://www.instagram.com/reel/TESTTEST/"
+
+# 1) retry succeeds when cookies help
+export OMNIGET_TOOL_YT_DLP="$tmp/yt-dlp"
+err="$tmp/e1"; out="$(og_run_ytdlp "$url" "$err" --print x 2>"$tmp/notice1")"; rc=$?
+check "retry: exit 0 when cookies unblock" "$rc" "0"
+check "retry: returns stub stdout" "$out" "OK title ||| 12 ||| Some Title"
+grep -q "retrying with" "$tmp/notice1" && echo "ok: retry: printed the retry notice" || { echo "FAIL: retry notice missing"; fail=1; }
+
+# 2) hard-fail: one retry, then give up non-zero (no infinite loop)
+export OMNIGET_TOOL_YT_DLP="$tmp/yt-dlp-hardfail"
+err="$tmp/e2"; out="$(og_run_ytdlp "$url" "$err" --print x 2>/dev/null)"; rc=$?
+check "hardfail: exit non-zero" "$rc" "1"
+check "hardfail: empty stdout" "$out" ""
+grep -qi "empty media" "$err" && echo "ok: hardfail: error captured to errfile" || { echo "FAIL: errfile empty"; fail=1; }
+
+# 3) non-retryable error (DRM) must NOT trigger a cookie retry
+export OMNIGET_TOOL_YT_DLP="$tmp/yt-dlp-drm"
+err="$tmp/e3"; og_run_ytdlp "$url" "$err" --print x >/dev/null 2>"$tmp/notice3"; rc=$?
+check "drm: exit non-zero" "$rc" "1"
+if grep -q "retrying with" "$tmp/notice3"; then echo "FAIL: drm should not retry"; fail=1; else echo "ok: drm: no retry attempted"; fi
+
+exit $fail