Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix: locate the pinned yt-dlp project as a Distribution package asset

fetw8e9c54c4e961
diff --git a/packages/yt-dlp/package.json b/packages/yt-dlp/package.json
index 79ae4c44..c1aa3c07 100644
--- a/packages/yt-dlp/package.json
+++ b/packages/yt-dlp/package.json
@@ -6,5 +6,9 @@
"type": "module",
"exports": {
".": "./src/index.ts"
+ },
+ "dependencies": {
+ "@hypit/package-loader-node": "workspace:*",
+ "@hypit/yt-dlp-service-runtime": "workspace:*"
}
}
diff --git a/packages/yt-dlp/src/download.ts b/packages/yt-dlp/src/download.ts
index 1a757fe1..57375bc5 100644
--- a/packages/yt-dlp/src/download.ts
+++ b/packages/yt-dlp/src/download.ts
@@ -11,11 +11,11 @@
* the same shape WhisperX and OpenCV already use for their Python programs.
*/
import { spawnSync } from "node:child_process";
-import { existsSync } from "node:fs";
import { copyFile, mkdtemp, readdir, rename, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, extname, join } from "node:path";
-import { fileURLToPath } from "node:url";
+
+import { resolveNodePackageResource } from "@hypit/package-loader-node";
/**
* Whether this is a link to fetch rather than a path to open.
@@ -34,20 +34,16 @@ export function isVideoUrl(value: string): boolean {
}
/**
- * The uv project holding the pinned `yt-dlp`, found by walking up from this module rather than from
- * the working directory, which is wherever the author happened to run the command from.
+ * The locked uv project is a Distribution package asset, the same way WhisperX and
+ * OpenCV locate their Python programs. Walking parents of this file only works
+ * while the module still sits above `services/` in a contributor checkout.
*/
function serviceProject(): string {
- let directory = dirname(fileURLToPath(import.meta.url));
- while (true) {
- const candidate = join(directory, "services", "yt-dlp", "pyproject.toml");
- if (existsSync(candidate)) return dirname(candidate);
- const parent = dirname(directory);
- if (parent === directory) {
- throw new Error("no services/yt-dlp project above this module; the Distribution is incomplete");
- }
- directory = parent;
- }
+ return dirname(resolveNodePackageResource(
+ "@hypit/yt-dlp-service-runtime",
+ "pyproject.toml",
+ { from: import.meta.url },
+ ));
}
/**
diff --git a/packages/yt-dlp/test/download.test.ts b/packages/yt-dlp/test/download.test.ts
new file mode 100644
index 00000000..cdc5b868
--- /dev/null
+++ b/packages/yt-dlp/test/download.test.ts
@@ -0,0 +1,27 @@
+import assert from "node:assert/strict";
+import { existsSync } from "node:fs";
+import { dirname, join } from "node:path";
+import test from "node:test";
+
+import { resolveNodePackageResource } from "@hypit/package-loader-node";
+
+import { isVideoUrl } from "../src/download.js";
+
+test("only http and https links are fetched; Windows paths stay files", () => {
+ assert.equal(isVideoUrl("https://youtu.be/example"), true);
+ assert.equal(isVideoUrl("http://example.test/clip.mp4"), true);
+ assert.equal(isVideoUrl("C:\\clip.mp4"), false);
+ assert.equal(isVideoUrl("c:\\clip.mp4"), false);
+ assert.equal(isVideoUrl("file:///tmp/clip.mp4"), false);
+ assert.equal(isVideoUrl("/tmp/clip.mp4"), false);
+});
+
+test("the pinned yt-dlp project is a Distribution package asset", () => {
+ const project = dirname(resolveNodePackageResource(
+ "@hypit/yt-dlp-service-runtime",
+ "pyproject.toml",
+ { from: import.meta.url },
+ ));
+ assert.ok(existsSync(join(project, "pyproject.toml")));
+ assert.ok(existsSync(join(project, "uv.lock")));
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7879ee08..875c4992 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -3492,7 +3492,14 @@ importers:
specifier: workspace:*
version: link:../workspace
- packages/yt-dlp: {}
+ packages/yt-dlp:
+ dependencies:
+ '@hypit/package-loader-node':
+ specifier: workspace:*
+ version: link:../package-loader-node
+ '@hypit/yt-dlp-service-runtime':
+ specifier: workspace:*
+ version: link:../../services/yt-dlp
services/image-opencv: {}