Add yt-dlp "Download Video" Chromium extension
Download the current page's video with yt-dlp via Alt+Shift+D or a click on the toolbar icon. A native-messaging host runs the download, shows live progress on the Quickshell OSD, and posts a clickable "Download complete" toast that opens the file in mpv. - Extension: pinned key for a stable id, green download-video icon, keyboard command + toolbar action (reads the active tab URL). - Native host (omarchy-chromium-ytdlp-host): verifies the URL with yt-dlp --simulate (else "No video found"), streams progress to the OSD (time-throttled to ~4/s), saves to ~/Videos, opens mpv on click. - Installer (omarchy-install-chromium-ytdlp) writes the native-messaging manifest into installed Chromium/Chrome/Brave/Edge profiles; wired into browser install and chromium refresh, with a migration for existing users. - omarchy-osd: add -d/--duration so the OSD can persist during a download. - Add yt-dlp to base packages, load the extension via --load-extension, and document the Alt+Shift+D binding. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1d6467c91c
commit
e5290b0a12
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
TMPDIR=""
|
||||
|
||||
export PATH="$ROOT/bin:$PATH"
|
||||
|
||||
cleanup() {
|
||||
[[ -n $TMPDIR && -d $TMPDIR ]] && rm -rf "$TMPDIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
require_command jq
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
test_home="$TMPDIR/home"
|
||||
manifest_path="$test_home/.config/chromium/NativeMessagingHosts/com.omarchy.ytdlp.json"
|
||||
|
||||
HOME="$test_home" OMARCHY_PATH="$ROOT" omarchy-install-chromium-ytdlp
|
||||
|
||||
[[ -f $manifest_path ]] || fail "yt-dlp native host installer creates fresh Chromium profile root"
|
||||
pass "yt-dlp native host installer creates fresh Chromium profile root"
|
||||
|
||||
jq -e --arg path "$ROOT/bin/omarchy-chromium-ytdlp-host" '
|
||||
.name == "com.omarchy.ytdlp" and
|
||||
.path == $path and
|
||||
(.allowed_origins | index("chrome-extension://dedjgknigfeelejglamclffonmophnfl/"))
|
||||
' "$manifest_path" >/dev/null
|
||||
pass "yt-dlp native host manifest uses Omarchy host path and extension id"
|
||||
|
||||
parse_result=$(bash -c '
|
||||
OMARCHY_PATH="$3"
|
||||
source "$1"
|
||||
parse_url "$2"
|
||||
' bash "$ROOT/bin/omarchy-chromium-ytdlp-host" '{"url":"https://example.test/watch?v=\"quoted\"&name=a\\b"}' "$ROOT")
|
||||
|
||||
[[ $parse_result == "https://example.test/watch?v=\"quoted\"&name=a\\b" ]] ||
|
||||
fail "yt-dlp native host parses escaped JSON URLs" "$parse_result"
|
||||
pass "yt-dlp native host parses escaped JSON URLs"
|
||||
|
||||
bash -c '
|
||||
OMARCHY_PATH="$3"
|
||||
source "$1"
|
||||
valid_url "$2"
|
||||
' bash "$ROOT/bin/omarchy-chromium-ytdlp-host" "javascript:alert(1)" "$ROOT" &&
|
||||
fail "yt-dlp native host rejects non-web URLs"
|
||||
pass "yt-dlp native host rejects non-web URLs"
|
||||
Reference in New Issue
Block a user