@mkterswingman/5mghost-yonder 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/auth/oauthFlow.d.ts +6 -0
- package/dist/auth/oauthFlow.js +151 -0
- package/dist/auth/tokenManager.d.ts +9 -0
- package/dist/auth/tokenManager.js +100 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +92 -0
- package/dist/cli/serve.d.ts +1 -0
- package/dist/cli/serve.js +24 -0
- package/dist/cli/setup.d.ts +1 -0
- package/dist/cli/setup.js +318 -0
- package/dist/cli/setupCookies.d.ts +34 -0
- package/dist/cli/setupCookies.js +196 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +79 -0
- package/dist/tools/remote.d.ts +4 -0
- package/dist/tools/remote.js +230 -0
- package/dist/tools/subtitles.d.ts +4 -0
- package/dist/tools/subtitles.js +579 -0
- package/dist/utils/config.d.ts +23 -0
- package/dist/utils/config.js +47 -0
- package/dist/utils/cookieRefresh.d.ts +18 -0
- package/dist/utils/cookieRefresh.js +70 -0
- package/dist/utils/cookies.d.ts +18 -0
- package/dist/utils/cookies.js +78 -0
- package/dist/utils/launcher.d.ts +12 -0
- package/dist/utils/launcher.js +82 -0
- package/dist/utils/mcpRegistration.d.ts +7 -0
- package/dist/utils/mcpRegistration.js +23 -0
- package/dist/utils/videoInput.d.ts +5 -0
- package/dist/utils/videoInput.js +55 -0
- package/dist/utils/ytdlp.d.ts +7 -0
- package/dist/utils/ytdlp.js +52 -0
- package/dist/utils/ytdlpPath.d.ts +26 -0
- package/dist/utils/ytdlpPath.js +78 -0
- package/package.json +43 -0
- package/scripts/download-ytdlp.mjs +138 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* postinstall script — downloads yt-dlp binary for the current platform.
|
|
5
|
+
*
|
|
6
|
+
* Runs automatically on `npm install`. Uses only Node.js built-ins (no deps).
|
|
7
|
+
*
|
|
8
|
+
* Env overrides:
|
|
9
|
+
* YT_MCP_SKIP_YTDLP=1 — skip download entirely (CI / air-gapped)
|
|
10
|
+
* YT_MCP_YTDLP_MIRROR — custom base URL (default: GitHub releases)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { createWriteStream, chmodSync, mkdirSync, existsSync } from "node:fs";
|
|
14
|
+
import { execFileSync } from "node:child_process";
|
|
15
|
+
import { join, dirname } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { pipeline } from "node:stream/promises";
|
|
18
|
+
|
|
19
|
+
// ── Constants ────────────────────────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
// Pinned version: upgrade by changing this constant + publishing new npm version.
|
|
22
|
+
// Avoids auto-update breaking compat. postinstall (not optionalDeps) because yt-dlp is a standalone binary.
|
|
23
|
+
const YT_DLP_VERSION = "2026.03.17";
|
|
24
|
+
|
|
25
|
+
const BASE_URL =
|
|
26
|
+
process.env.YT_MCP_YTDLP_MIRROR ||
|
|
27
|
+
`https://github.com/yt-dlp/yt-dlp/releases/download/${YT_DLP_VERSION}`;
|
|
28
|
+
|
|
29
|
+
/** Map (platform, arch) → binary file name on GitHub Releases. */
|
|
30
|
+
const PLATFORM_MAP = {
|
|
31
|
+
"darwin-arm64": "yt-dlp_macos",
|
|
32
|
+
"darwin-x64": "yt-dlp_macos",
|
|
33
|
+
"linux-x64": "yt-dlp_linux",
|
|
34
|
+
"linux-arm64": "yt-dlp_linux_aarch64",
|
|
35
|
+
"win32-x64": "yt-dlp.exe",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
41
|
+
const pkgRoot = join(__dirname, "..");
|
|
42
|
+
const binDir = join(pkgRoot, "bin");
|
|
43
|
+
|
|
44
|
+
function localName() {
|
|
45
|
+
return process.platform === "win32" ? "yt-dlp.exe" : "yt-dlp";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Follow redirects (GitHub releases → S3) and stream to disk.
|
|
50
|
+
* Uses global fetch() (Node 18+).
|
|
51
|
+
*/
|
|
52
|
+
async function download(url, dest) {
|
|
53
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
throw new Error(`HTTP ${res.status} ${res.statusText} — ${url}`);
|
|
56
|
+
}
|
|
57
|
+
const fileStream = createWriteStream(dest);
|
|
58
|
+
// res.body is a ReadableStream; convert to Node stream for pipeline
|
|
59
|
+
await pipeline(res.body, fileStream);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ── Main ─────────────────────────────────────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
async function main() {
|
|
65
|
+
// Allow skipping for CI or air-gapped environments
|
|
66
|
+
if (process.env.YT_MCP_SKIP_YTDLP === "1") {
|
|
67
|
+
console.log("[yt-mcp] YT_MCP_SKIP_YTDLP=1 — skipping yt-dlp download");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const key = `${process.platform}-${process.arch}`;
|
|
72
|
+
const remoteName = PLATFORM_MAP[key];
|
|
73
|
+
|
|
74
|
+
if (!remoteName) {
|
|
75
|
+
console.warn(
|
|
76
|
+
`[yt-mcp] ⚠️ No pre-built yt-dlp binary for ${key}. ` +
|
|
77
|
+
`Install yt-dlp manually: https://github.com/yt-dlp/yt-dlp#installation`
|
|
78
|
+
);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const dest = join(binDir, localName());
|
|
83
|
+
|
|
84
|
+
// Already downloaded?
|
|
85
|
+
if (existsSync(dest)) {
|
|
86
|
+
console.log(`[yt-mcp] yt-dlp already present at ${dest}`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
mkdirSync(binDir, { recursive: true });
|
|
91
|
+
|
|
92
|
+
const url = `${BASE_URL}/${remoteName}`;
|
|
93
|
+
// Keep logs minimal — setup.ts controls user-facing output.
|
|
94
|
+
// These only show during direct `node scripts/download-ytdlp.mjs` or postinstall.
|
|
95
|
+
const verbose = !process.env.YT_MCP_QUIET;
|
|
96
|
+
|
|
97
|
+
if (verbose) console.log(`[yt-mcp] Downloading yt-dlp...`);
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
await download(url, dest);
|
|
101
|
+
|
|
102
|
+
// chmod +x on non-Windows
|
|
103
|
+
if (process.platform !== "win32") {
|
|
104
|
+
chmodSync(dest, 0o755);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// macOS Gatekeeper: clear quarantine/provenance xattr so Node.js
|
|
108
|
+
// execFileSync doesn't hang waiting for a UI prompt that never appears.
|
|
109
|
+
if (process.platform === "darwin") {
|
|
110
|
+
try {
|
|
111
|
+
execFileSync("xattr", ["-cr", dest], { stdio: "ignore" });
|
|
112
|
+
} catch {
|
|
113
|
+
// xattr may fail in sandboxed environments — non-fatal
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Pre-run to trigger macOS Gatekeeper verification and cache the result.
|
|
118
|
+
// First execution of an ad-hoc signed binary takes ~15-20s for the network
|
|
119
|
+
// check. Doing it here (during install) means setup/serve won't wait.
|
|
120
|
+
try {
|
|
121
|
+
execFileSync(dest, ["--version"], {
|
|
122
|
+
stdio: "ignore",
|
|
123
|
+
timeout: 60_000,
|
|
124
|
+
});
|
|
125
|
+
if (verbose) console.log(`[yt-mcp] ✅ yt-dlp ready`);
|
|
126
|
+
} catch {
|
|
127
|
+
if (verbose) console.log(`[yt-mcp] ✅ yt-dlp installed`);
|
|
128
|
+
}
|
|
129
|
+
} catch (err) {
|
|
130
|
+
console.error(`[yt-mcp] ⚠️ Failed to download yt-dlp: ${err.message}`);
|
|
131
|
+
console.error(
|
|
132
|
+
`[yt-mcp] Install manually: https://github.com/yt-dlp/yt-dlp#installation`
|
|
133
|
+
);
|
|
134
|
+
// Non-fatal — remote tools still work without yt-dlp
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
main();
|