From 7638b504cf6163e26d18117961486327dfd820f1 Mon Sep 17 00:00:00 2001 From: Ai Dark Date: Tue, 18 Aug 2026 22:11:59 +0600 Subject: [PATCH] fix(ytdlp): enable Node JS challenges and bundle Linux runtime Pass the running Node binary to yt-dlp for YouTube JS challenges. Install the official yt-dlp Linux bundle to remove the system Python dependency. --- docs/dependencies.md | 2 +- scripts/setup/dependency-versions.sh | 2 +- scripts/setup/install-dependencies.sh | 2 +- scripts/tests/http-test-helpers.mjs | 4 ++++ src/lib/ytdlp.ts | 2 +- src/vendor/node.d.ts | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/dependencies.md b/docs/dependencies.md index 7636c4e..a8cd14d 100644 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -9,7 +9,7 @@ The runtime dependency model is intentionally small: - Node.js 24 provides the application runtime and built-in APIs. Production uses the pinned official Linux x64 release tarball installed by `scripts/setup/install-dependencies.sh` under `runtime/node`. - Browser code uses native ES modules and DOM APIs. - SQLite is accessed through the Node runtime API used by this project. -- `yt-dlp` is a pinned system binary installed outside npm by `scripts/setup/install-dependencies.sh`. +- `yt-dlp` is the pinned official Linux x64 bundled binary installed outside npm by `scripts/setup/install-dependencies.sh`. The server-side wrapper explicitly supplies the pinned Node runtime for YouTube JavaScript challenges. - nginx, certbot, and systemd are system-level runtime tools. - `curl` is a deployment-health tool and is also used by the proxy-check service when a proxy check is configured. diff --git a/scripts/setup/dependency-versions.sh b/scripts/setup/dependency-versions.sh index 500e254..cc94e98 100644 --- a/scripts/setup/dependency-versions.sh +++ b/scripts/setup/dependency-versions.sh @@ -4,6 +4,6 @@ readonly NODE_VERSION=24.19.0 readonly NODE_SHA256=f625d97cd707df4ff96254916fbc5ff014f09c09effe5a1e0ca8f6d41a8789d4 readonly YTDLP_VERSION=2026.07.04 -readonly YTDLP_SHA256=495be29ff4d9d4e9be7eabdfef225221e5d5282e77f2f505abc6dca80349f3fd +readonly YTDLP_SHA256=6bbb3d314cde4febe36e5fa1d55462e29c974f63444e707871834f6d8cc210ae readonly TYPESCRIPT_VERSION=6.0.3 readonly BIOME_VERSION=2.4.12 diff --git a/scripts/setup/install-dependencies.sh b/scripts/setup/install-dependencies.sh index 2d7ece6..369abb4 100644 --- a/scripts/setup/install-dependencies.sh +++ b/scripts/setup/install-dependencies.sh @@ -89,7 +89,7 @@ echo "Node.js version: $(${NODE_BIN} --version)" echo "=== Installing yt-dlp ${YTDLP_VERSION} ===" YTDLP_TMP="$(mktemp)" -curl -fsSL "https://github.com/yt-dlp/yt-dlp/releases/download/${YTDLP_VERSION}/yt-dlp" -o "${YTDLP_TMP}" +curl -fsSL "https://github.com/yt-dlp/yt-dlp/releases/download/${YTDLP_VERSION}/yt-dlp_linux" -o "${YTDLP_TMP}" echo "${YTDLP_SHA256} ${YTDLP_TMP}" | sha256sum -c - install -o root -g root -m 0755 "${YTDLP_TMP}" /usr/local/bin/yt-dlp rm -f "${YTDLP_TMP}" diff --git a/scripts/tests/http-test-helpers.mjs b/scripts/tests/http-test-helpers.mjs index 33f0d2d..dc36aaa 100644 --- a/scripts/tests/http-test-helpers.mjs +++ b/scripts/tests/http-test-helpers.mjs @@ -18,6 +18,10 @@ export async function createHttpHarness(name) { await writeFile( fakeYtDlp, `#!/bin/sh +case "$*" in + *--js-runtimes\\ node:*) ;; + *) echo "yt-dlp must receive the Node.js runtime" >&2; exit 1 ;; +esac case "$*" in *failmeta001*) echo "metadata failed" >&2; exit 1 ;; esac diff --git a/src/lib/ytdlp.ts b/src/lib/ytdlp.ts index bed2cd9..677b13e 100644 --- a/src/lib/ytdlp.ts +++ b/src/lib/ytdlp.ts @@ -48,7 +48,7 @@ export interface CrawlResult { // ── Internal ────────────────────────────────────────────────────────────────── function baseArgs(): string[] { - const args: string[] = []; + const args: string[] = ['--js-runtimes', `node:${process.execPath}`]; if (config.YTDLP_PROXY) args.push('--proxy', config.YTDLP_PROXY); if (config.YTDLP_COOKIES) args.push('--cookies', config.YTDLP_COOKIES); return args; diff --git a/src/vendor/node.d.ts b/src/vendor/node.d.ts index 4f6b22f..ee922ff 100644 --- a/src/vendor/node.d.ts +++ b/src/vendor/node.d.ts @@ -36,6 +36,7 @@ declare function clearInterval(id: unknown): void; declare const process: { env: Record; argv: string[]; + execPath: string; cwd(): string; on(event: 'SIGTERM' | 'SIGINT', listener: () => void): void; exit(code?: number): never;