yt-dlp-bridge 0.1.0
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/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/argv.d.ts +18 -0
- package/dist/argv.d.ts.map +1 -0
- package/dist/argv.js +276 -0
- package/dist/argv.js.map +1 -0
- package/dist/config.d.ts +20 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/environment.d.ts +27 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +80 -0
- package/dist/environment.js.map +1 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +73 -0
- package/dist/errors.js.map +1 -0
- package/dist/filesystem.d.ts +23 -0
- package/dist/filesystem.d.ts.map +1 -0
- package/dist/filesystem.js +57 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/generated/ytdlp-options.json +5513 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/option-catalog.d.ts +34 -0
- package/dist/option-catalog.d.ts.map +1 -0
- package/dist/option-catalog.js +89 -0
- package/dist/option-catalog.js.map +1 -0
- package/dist/parsers.d.ts +11 -0
- package/dist/parsers.d.ts.map +1 -0
- package/dist/parsers.js +268 -0
- package/dist/parsers.js.map +1 -0
- package/dist/planner.d.ts +10 -0
- package/dist/planner.d.ts.map +1 -0
- package/dist/planner.js +233 -0
- package/dist/planner.js.map +1 -0
- package/dist/redaction.d.ts +4 -0
- package/dist/redaction.d.ts.map +1 -0
- package/dist/redaction.js +52 -0
- package/dist/redaction.js.map +1 -0
- package/dist/runner.d.ts +14 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +78 -0
- package/dist/runner.js.map +1 -0
- package/dist/schemas.d.ts +818 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +179 -0
- package/dist/schemas.js.map +1 -0
- package/dist/types.d.ts +163 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Antonio Orionus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# yt-dlp-bridge
|
|
2
|
+
|
|
3
|
+
Typed, source-derived yt-dlp command planning and execution primitives for Node.js.
|
|
4
|
+
|
|
5
|
+
This package is intentionally MCP-agnostic. It provides the yt-dlp integration layer used by `yt-dlp-mcp-server`: option catalog access, safe argv generation, dependency-aware planning, process execution, redaction, filesystem policy, and structured error adaptation via `ytdlp-errors`.
|
|
6
|
+
|
|
7
|
+
## Local pre-release use
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
cd /home/anton/projects/y/yt-dlp-bridge
|
|
11
|
+
pnpm install
|
|
12
|
+
pnpm test
|
|
13
|
+
pnpm run typecheck
|
|
14
|
+
pnpm run build
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Node >= 20. ESM only.
|
|
18
|
+
|
|
19
|
+
This package is not published yet. It currently depends on the sibling local `ytdlp-errors` package via `file:../ytdlp-errors` so the full yt-dlp MCP stack can be polished before release.
|
package/dist/argv.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { type ServerConfig } from "./config.js";
|
|
3
|
+
import { type ResolvedOutputPolicy } from "./filesystem.js";
|
|
4
|
+
import { type DownloadInputSchema, type InspectInputSchema, type PlanDownloadInputSchema } from "./schemas.js";
|
|
5
|
+
import type { YtdlpCommand } from "./types.js";
|
|
6
|
+
type InspectInput = z.infer<typeof InspectInputSchema>;
|
|
7
|
+
type PlanDownloadInput = z.infer<typeof PlanDownloadInputSchema>;
|
|
8
|
+
type DownloadInput = z.infer<typeof DownloadInputSchema>;
|
|
9
|
+
type DownloadLikeInput = PlanDownloadInput | DownloadInput;
|
|
10
|
+
export type ListKind = "formats" | "subtitles" | "thumbnails";
|
|
11
|
+
export declare function ytdlpCommand(args: string[], config?: ServerConfig): YtdlpCommand;
|
|
12
|
+
export declare function buildMetadataArgs(input: InspectInput, config?: ServerConfig): string[];
|
|
13
|
+
export declare function buildSingleJsonArgs(input: InspectInput, config?: ServerConfig): string[];
|
|
14
|
+
export declare function buildListArgs(kind: ListKind, input: InspectInput, config?: ServerConfig): string[];
|
|
15
|
+
export declare function buildSimulationArgs(input: DownloadLikeInput, policy: ResolvedOutputPolicy, config?: ServerConfig): string[];
|
|
16
|
+
export declare function buildDownloadArgs(input: DownloadLikeInput, policy: ResolvedOutputPolicy, config?: ServerConfig): string[];
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=argv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argv.d.ts","sourceRoot":"","sources":["../src/argv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,KAAK,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACvD,KAAK,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACjE,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACzD,KAAK,iBAAiB,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAE3D,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,YAAY,CAAC;AAE9D,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,YAAqB,GAAG,YAAY,CAMxF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,GAAE,YAAqB,GAAG,MAAM,EAAE,CAE9F;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,GAAE,YAAqB,GAAG,MAAM,EAAE,CAEhG;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,GAAE,YAAqB,GAAG,MAAM,EAAE,CAG1G;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,GAAE,YAAqB,GAAG,MAAM,EAAE,CAEnI;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,GAAE,YAAqB,GAAG,MAAM,EAAE,CAkCjI"}
|
package/dist/argv.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { CONFIG } from "./config.js";
|
|
2
|
+
import { resolveManagedPath } from "./filesystem.js";
|
|
3
|
+
import { redactArgs } from "./redaction.js";
|
|
4
|
+
import {} from "./schemas.js";
|
|
5
|
+
export function ytdlpCommand(args, config = CONFIG) {
|
|
6
|
+
return {
|
|
7
|
+
command: config.ytdlpPath,
|
|
8
|
+
args,
|
|
9
|
+
redactedArgs: redactArgs(args)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function buildMetadataArgs(input, config = CONFIG) {
|
|
13
|
+
return [...buildInspectBaseArgs(input, config), "--dump-json", input.url];
|
|
14
|
+
}
|
|
15
|
+
export function buildSingleJsonArgs(input, config = CONFIG) {
|
|
16
|
+
return [...buildInspectBaseArgs(input, config), "--dump-single-json", input.url];
|
|
17
|
+
}
|
|
18
|
+
export function buildListArgs(kind, input, config = CONFIG) {
|
|
19
|
+
const flag = kind === "formats" ? "--list-formats" : kind === "subtitles" ? "--list-subs" : "--list-thumbnails";
|
|
20
|
+
return [...buildInspectBaseArgs(input, config), flag, input.url];
|
|
21
|
+
}
|
|
22
|
+
export function buildSimulationArgs(input, policy, config = CONFIG) {
|
|
23
|
+
return ["--simulate", ...buildDownloadArgs(input, policy, config)];
|
|
24
|
+
}
|
|
25
|
+
export function buildDownloadArgs(input, policy, config = CONFIG) {
|
|
26
|
+
const args = buildBaseArgs(input, config);
|
|
27
|
+
push(args, "--paths", `home:${policy.outputRoot}`);
|
|
28
|
+
push(args, "--paths", `temp:${policy.tempRoot}`);
|
|
29
|
+
push(args, "--output", policy.outputTemplate);
|
|
30
|
+
args.push(policy.allowOverwrite ? "--force-overwrites" : "--no-overwrites");
|
|
31
|
+
args.push("--newline", "--progress");
|
|
32
|
+
push(args, "--print", "after_move:filepath");
|
|
33
|
+
appendSelectionArgs(args, input, policy, config);
|
|
34
|
+
appendDownloadArgs(args, input);
|
|
35
|
+
appendFormatArgs(args, input);
|
|
36
|
+
appendSubtitleArgs(args, input);
|
|
37
|
+
appendThumbnailArgs(args, input);
|
|
38
|
+
appendPostprocessArgs(args, input);
|
|
39
|
+
appendSponsorBlockArgs(args, input);
|
|
40
|
+
appendExtractorArgs(args, input);
|
|
41
|
+
if (input.kind === "audio" && !input.postprocess.extractAudio) {
|
|
42
|
+
args.push("--extract-audio");
|
|
43
|
+
}
|
|
44
|
+
if (input.kind === "subtitles") {
|
|
45
|
+
args.push("--skip-download");
|
|
46
|
+
if (!input.subtitles.writeSubs && !input.subtitles.writeAutoSubs)
|
|
47
|
+
args.push("--write-subs");
|
|
48
|
+
}
|
|
49
|
+
if (input.kind === "thumbnail") {
|
|
50
|
+
args.push("--skip-download");
|
|
51
|
+
if (!input.thumbnails.writeThumbnail && !input.thumbnails.writeAllThumbnails)
|
|
52
|
+
args.push("--write-thumbnail");
|
|
53
|
+
}
|
|
54
|
+
if (input.kind === "playlist" && !input.selection.noPlaylist)
|
|
55
|
+
args.push("--yes-playlist");
|
|
56
|
+
args.push(input.url);
|
|
57
|
+
return args;
|
|
58
|
+
}
|
|
59
|
+
function buildInspectBaseArgs(input, config) {
|
|
60
|
+
const args = buildBaseArgs(input, config);
|
|
61
|
+
if (input.flatPlaylist)
|
|
62
|
+
args.push("--flat-playlist");
|
|
63
|
+
return args;
|
|
64
|
+
}
|
|
65
|
+
function buildBaseArgs(input, config) {
|
|
66
|
+
const args = ["--ignore-config", "--no-warnings"];
|
|
67
|
+
appendNetworkArgs(args, input.network);
|
|
68
|
+
appendAuthArgs(args, input.auth, config);
|
|
69
|
+
return args;
|
|
70
|
+
}
|
|
71
|
+
function appendNetworkArgs(args, network) {
|
|
72
|
+
push(args, "--proxy", network.proxy);
|
|
73
|
+
if (network.socketTimeout !== undefined)
|
|
74
|
+
push(args, "--socket-timeout", String(network.socketTimeout));
|
|
75
|
+
push(args, "--source-address", network.sourceAddress);
|
|
76
|
+
push(args, "--impersonate", network.impersonate);
|
|
77
|
+
push(args, "--geo-verification-proxy", network.geoVerificationProxy);
|
|
78
|
+
push(args, "--xff", network.xff);
|
|
79
|
+
if (network.forceIpv4)
|
|
80
|
+
args.push("--force-ipv4");
|
|
81
|
+
if (network.forceIpv6)
|
|
82
|
+
args.push("--force-ipv6");
|
|
83
|
+
}
|
|
84
|
+
function appendAuthArgs(args, auth, config) {
|
|
85
|
+
push(args, "--username", auth.username);
|
|
86
|
+
push(args, "--password", auth.password);
|
|
87
|
+
push(args, "--twofactor", auth.twofactor);
|
|
88
|
+
if (auth.netrc) {
|
|
89
|
+
requireConfigFilePolicy("auth.netrc", config);
|
|
90
|
+
args.push("--netrc");
|
|
91
|
+
}
|
|
92
|
+
if (auth.netrcLocation)
|
|
93
|
+
requireConfigFilePolicy("auth.netrcLocation", config);
|
|
94
|
+
if (auth.netrcCmd)
|
|
95
|
+
requireConfigFilePolicy("auth.netrcCmd", config);
|
|
96
|
+
push(args, "--netrc-location", auth.netrcLocation);
|
|
97
|
+
push(args, "--netrc-cmd", auth.netrcCmd);
|
|
98
|
+
push(args, "--video-password", auth.videoPassword);
|
|
99
|
+
push(args, "--cookies", configuredOrAllowed(auth.cookiesFile, config.cookiesFile, "auth.cookiesFile", config));
|
|
100
|
+
push(args, "--cookies-from-browser", configuredOrAllowed(auth.cookiesFromBrowser, config.cookiesFromBrowser, "auth.cookiesFromBrowser", config));
|
|
101
|
+
}
|
|
102
|
+
function appendSelectionArgs(args, input, policy, config) {
|
|
103
|
+
const selection = input.selection;
|
|
104
|
+
push(args, "--playlist-items", selection.playlistItems);
|
|
105
|
+
if (selection.noPlaylist)
|
|
106
|
+
args.push("--no-playlist");
|
|
107
|
+
if (selection.yesPlaylist)
|
|
108
|
+
args.push("--yes-playlist");
|
|
109
|
+
push(args, "--min-filesize", selection.minFilesize);
|
|
110
|
+
push(args, "--max-filesize", selection.maxFilesize);
|
|
111
|
+
push(args, "--date", selection.date);
|
|
112
|
+
push(args, "--datebefore", selection.dateBefore);
|
|
113
|
+
push(args, "--dateafter", selection.dateAfter);
|
|
114
|
+
pushRepeated(args, "--match-filters", selection.matchFilters);
|
|
115
|
+
pushRepeated(args, "--break-match-filters", selection.breakMatchFilters);
|
|
116
|
+
if (selection.ageLimit !== undefined)
|
|
117
|
+
push(args, "--age-limit", String(selection.ageLimit));
|
|
118
|
+
push(args, "--download-archive", selection.downloadArchive ? resolveManagedPath(policy.outputRoot, selection.downloadArchive, "downloadArchive", config.allowArbitraryOutputPaths) : undefined);
|
|
119
|
+
if (selection.maxDownloads !== undefined)
|
|
120
|
+
push(args, "--max-downloads", String(selection.maxDownloads));
|
|
121
|
+
if (selection.breakOnExisting)
|
|
122
|
+
args.push("--break-on-existing");
|
|
123
|
+
if (selection.breakPerInput)
|
|
124
|
+
args.push("--break-per-input");
|
|
125
|
+
if (selection.skipPlaylistAfterErrors !== undefined)
|
|
126
|
+
push(args, "--skip-playlist-after-errors", String(selection.skipPlaylistAfterErrors));
|
|
127
|
+
}
|
|
128
|
+
function configuredOrAllowed(inputValue, configuredValue, label, config) {
|
|
129
|
+
if (inputValue !== undefined && inputValue !== configuredValue)
|
|
130
|
+
requireConfigFilePolicy(label, config);
|
|
131
|
+
return inputValue ?? configuredValue;
|
|
132
|
+
}
|
|
133
|
+
function requireConfigFilePolicy(label, config) {
|
|
134
|
+
if (!config.allowConfigFiles)
|
|
135
|
+
throw new Error(`${label} requires YTDLP_MCP_ALLOW_CONFIG_FILES=true or a matching server-level environment setting`);
|
|
136
|
+
}
|
|
137
|
+
function appendDownloadArgs(args, input) {
|
|
138
|
+
const download = input.download;
|
|
139
|
+
if (download.concurrentFragments !== undefined)
|
|
140
|
+
push(args, "--concurrent-fragments", String(download.concurrentFragments));
|
|
141
|
+
push(args, "--limit-rate", download.limitRate);
|
|
142
|
+
push(args, "--throttled-rate", download.throttledRate);
|
|
143
|
+
push(args, "--retries", download.retries);
|
|
144
|
+
push(args, "--file-access-retries", download.fileAccessRetries);
|
|
145
|
+
push(args, "--fragment-retries", download.fragmentRetries);
|
|
146
|
+
pushRepeated(args, "--retry-sleep", download.retrySleep);
|
|
147
|
+
if (download.keepFragments)
|
|
148
|
+
args.push("--keep-fragments");
|
|
149
|
+
push(args, "--buffer-size", download.bufferSize);
|
|
150
|
+
push(args, "--http-chunk-size", download.httpChunkSize);
|
|
151
|
+
if (download.playlistRandom)
|
|
152
|
+
args.push("--playlist-random");
|
|
153
|
+
if (download.lazyPlaylist)
|
|
154
|
+
args.push("--lazy-playlist");
|
|
155
|
+
if (download.hlsUseMpegts)
|
|
156
|
+
args.push("--hls-use-mpegts");
|
|
157
|
+
pushRepeated(args, "--download-sections", download.downloadSections);
|
|
158
|
+
pushRepeated(args, "--downloader", download.downloader);
|
|
159
|
+
pushRepeated(args, "--downloader-args", download.downloaderArgs);
|
|
160
|
+
}
|
|
161
|
+
function appendFormatArgs(args, input) {
|
|
162
|
+
const format = input.format;
|
|
163
|
+
push(args, "--format", format.format);
|
|
164
|
+
pushRepeated(args, "--format-sort", format.formatSort);
|
|
165
|
+
if (format.formatSortReset)
|
|
166
|
+
args.push("--format-sort-reset");
|
|
167
|
+
if (format.formatSortForce)
|
|
168
|
+
args.push("--format-sort-force");
|
|
169
|
+
if (format.videoMultistreams)
|
|
170
|
+
args.push("--video-multistreams");
|
|
171
|
+
if (format.audioMultistreams)
|
|
172
|
+
args.push("--audio-multistreams");
|
|
173
|
+
if (format.preferFreeFormats)
|
|
174
|
+
args.push("--prefer-free-formats");
|
|
175
|
+
if (format.checkFormats)
|
|
176
|
+
args.push("--check-formats");
|
|
177
|
+
if (format.checkAllFormats)
|
|
178
|
+
args.push("--check-all-formats");
|
|
179
|
+
push(args, "--merge-output-format", format.mergeOutputFormat);
|
|
180
|
+
}
|
|
181
|
+
function appendSubtitleArgs(args, input) {
|
|
182
|
+
const subtitles = input.subtitles;
|
|
183
|
+
if (subtitles.writeSubs)
|
|
184
|
+
args.push("--write-subs");
|
|
185
|
+
if (subtitles.writeAutoSubs)
|
|
186
|
+
args.push("--write-auto-subs");
|
|
187
|
+
push(args, "--sub-format", subtitles.subFormat);
|
|
188
|
+
push(args, "--sub-langs", subtitles.subLangs);
|
|
189
|
+
push(args, "--convert-subs", subtitles.convertSubs);
|
|
190
|
+
}
|
|
191
|
+
function appendThumbnailArgs(args, input) {
|
|
192
|
+
const thumbnails = input.thumbnails;
|
|
193
|
+
if (thumbnails.writeThumbnail)
|
|
194
|
+
args.push("--write-thumbnail");
|
|
195
|
+
if (thumbnails.writeAllThumbnails)
|
|
196
|
+
args.push("--write-all-thumbnails");
|
|
197
|
+
push(args, "--convert-thumbnails", thumbnails.convertThumbnails);
|
|
198
|
+
}
|
|
199
|
+
function appendPostprocessArgs(args, input) {
|
|
200
|
+
const postprocess = input.postprocess;
|
|
201
|
+
if (postprocess.extractAudio)
|
|
202
|
+
args.push("--extract-audio");
|
|
203
|
+
push(args, "--audio-format", postprocess.audioFormat);
|
|
204
|
+
push(args, "--audio-quality", postprocess.audioQuality);
|
|
205
|
+
push(args, "--remux-video", postprocess.remuxVideo);
|
|
206
|
+
push(args, "--recode-video", postprocess.recodeVideo);
|
|
207
|
+
pushRepeated(args, "--postprocessor-args", postprocess.postprocessorArgs);
|
|
208
|
+
if (postprocess.keepVideo)
|
|
209
|
+
args.push("--keep-video");
|
|
210
|
+
if (postprocess.postOverwrites)
|
|
211
|
+
args.push("--post-overwrites");
|
|
212
|
+
if (postprocess.embedSubs)
|
|
213
|
+
args.push("--embed-subs");
|
|
214
|
+
if (postprocess.embedThumbnail)
|
|
215
|
+
args.push("--embed-thumbnail");
|
|
216
|
+
if (postprocess.embedMetadata)
|
|
217
|
+
args.push("--embed-metadata");
|
|
218
|
+
if (postprocess.embedChapters)
|
|
219
|
+
args.push("--embed-chapters");
|
|
220
|
+
if (postprocess.embedInfoJson)
|
|
221
|
+
args.push("--embed-info-json");
|
|
222
|
+
pushRepeated(args, "--parse-metadata", postprocess.parseMetadata);
|
|
223
|
+
pushRepeated(args, "--replace-in-metadata", postprocess.replaceInMetadata);
|
|
224
|
+
if (postprocess.xattrs)
|
|
225
|
+
args.push("--xattrs");
|
|
226
|
+
push(args, "--concat-playlist", postprocess.concatPlaylist);
|
|
227
|
+
push(args, "--fixup", postprocess.fixup);
|
|
228
|
+
if (postprocess.splitChapters)
|
|
229
|
+
args.push("--split-chapters");
|
|
230
|
+
pushRepeated(args, "--remove-chapters", postprocess.removeChapters);
|
|
231
|
+
if (postprocess.forceKeyframesAtCuts)
|
|
232
|
+
args.push("--force-keyframes-at-cuts");
|
|
233
|
+
pushRepeated(args, "--use-postprocessor", postprocess.usePostprocessor);
|
|
234
|
+
}
|
|
235
|
+
function appendSponsorBlockArgs(args, input) {
|
|
236
|
+
push(args, "--sponsorblock-mark", input.sponsorblock.mark);
|
|
237
|
+
push(args, "--sponsorblock-remove", input.sponsorblock.remove);
|
|
238
|
+
push(args, "--sponsorblock-chapter-title", input.sponsorblock.chapterTitle);
|
|
239
|
+
push(args, "--sponsorblock-api", input.sponsorblock.api);
|
|
240
|
+
}
|
|
241
|
+
function appendExtractorArgs(args, input) {
|
|
242
|
+
const extractor = input.extractor;
|
|
243
|
+
push(args, "--extractor-retries", extractor.extractorRetries);
|
|
244
|
+
if (extractor.allowDynamicMpd)
|
|
245
|
+
args.push("--allow-dynamic-mpd");
|
|
246
|
+
if (extractor.hlsSplitDiscontinuity)
|
|
247
|
+
args.push("--hls-split-discontinuity");
|
|
248
|
+
pushRepeated(args, "--extractor-args", extractor.extractorArgs);
|
|
249
|
+
const youtube = extractor.youtube;
|
|
250
|
+
if (!youtube)
|
|
251
|
+
return;
|
|
252
|
+
push(args, "--extractor-args", keyed("youtube", "lang", youtube.lang));
|
|
253
|
+
push(args, "--extractor-args", keyed("youtube", "comment_sort", youtube.commentSort));
|
|
254
|
+
push(args, "--extractor-args", keyed("youtube", "max_comments", youtube.maxComments));
|
|
255
|
+
push(args, "--extractor-args", keyed("youtube", "fetch_pot", youtube.fetchPot));
|
|
256
|
+
pushJoined(args, "youtube", "skip", youtube.skip);
|
|
257
|
+
pushJoined(args, "youtube", "player_client", youtube.playerClient);
|
|
258
|
+
pushJoined(args, "youtube", "formats", youtube.formats);
|
|
259
|
+
pushJoined(args, "youtube", "po_token", youtube.poToken);
|
|
260
|
+
}
|
|
261
|
+
function keyed(namespace, key, value) {
|
|
262
|
+
return value ? `${namespace}:${key}=${value}` : undefined;
|
|
263
|
+
}
|
|
264
|
+
function pushJoined(args, namespace, key, values) {
|
|
265
|
+
if (values.length > 0)
|
|
266
|
+
push(args, "--extractor-args", `${namespace}:${key}=${values.join(",")}`);
|
|
267
|
+
}
|
|
268
|
+
function push(args, flag, value) {
|
|
269
|
+
if (value !== undefined && value !== "")
|
|
270
|
+
args.push(flag, value);
|
|
271
|
+
}
|
|
272
|
+
function pushRepeated(args, flag, values) {
|
|
273
|
+
for (const value of values)
|
|
274
|
+
push(args, flag, value);
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=argv.js.map
|
package/dist/argv.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argv.js","sourceRoot":"","sources":["../src/argv.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAA6B,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAIN,MAAM,cAAc,CAAC;AAUtB,MAAM,UAAU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B;IAClE,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ServerConfig {
|
|
2
|
+
ytdlpPath: string;
|
|
3
|
+
ffmpegPath?: string | undefined;
|
|
4
|
+
ffprobePath?: string | undefined;
|
|
5
|
+
outputRoot: string;
|
|
6
|
+
tempRoot: string;
|
|
7
|
+
allowArbitraryOutputPaths: boolean;
|
|
8
|
+
allowConfigFiles: boolean;
|
|
9
|
+
allowPluginDirs: boolean;
|
|
10
|
+
enableExpertMode: boolean;
|
|
11
|
+
defaultTimeoutMs: number;
|
|
12
|
+
maxOutputBytes: number;
|
|
13
|
+
cookiesFile?: string | undefined;
|
|
14
|
+
cookiesFromBrowser?: string | undefined;
|
|
15
|
+
jsRuntimes: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function expandHome(input: string): string;
|
|
18
|
+
export declare function loadConfig(env?: NodeJS.ProcessEnv): ServerConfig;
|
|
19
|
+
export declare const CONFIG: ServerConfig;
|
|
20
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,OAAO,CAAC;IACnC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAWD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,YAAY,CAiB7E;AAED,eAAO,MAAM,MAAM,cAAe,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
function bool(value) {
|
|
4
|
+
return value ? ["1", "true", "yes", "on"].includes(value.toLowerCase()) : false;
|
|
5
|
+
}
|
|
6
|
+
function int(value, fallback) {
|
|
7
|
+
const parsed = value ? Number.parseInt(value, 10) : Number.NaN;
|
|
8
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
9
|
+
}
|
|
10
|
+
export function expandHome(input) {
|
|
11
|
+
if (input === "~")
|
|
12
|
+
return os.homedir();
|
|
13
|
+
if (input.startsWith("~/") || input.startsWith("~\\"))
|
|
14
|
+
return path.join(os.homedir(), input.slice(2));
|
|
15
|
+
return input;
|
|
16
|
+
}
|
|
17
|
+
export function loadConfig(env = process.env) {
|
|
18
|
+
return {
|
|
19
|
+
ytdlpPath: env.YTDLP_MCP_YTDLP_PATH ?? env.YTDLP_PATH ?? "yt-dlp",
|
|
20
|
+
ffmpegPath: env.YTDLP_MCP_FFMPEG_PATH ?? env.FFMPEG_PATH,
|
|
21
|
+
ffprobePath: env.YTDLP_MCP_FFPROBE_PATH ?? env.FFPROBE_PATH,
|
|
22
|
+
outputRoot: path.resolve(expandHome(env.YTDLP_MCP_OUTPUT_ROOT ?? path.join(os.homedir(), "Downloads", "yt-dlp-mcp"))),
|
|
23
|
+
tempRoot: path.resolve(expandHome(env.YTDLP_MCP_TEMP_ROOT ?? path.join(os.tmpdir(), "yt-dlp-mcp"))),
|
|
24
|
+
allowArbitraryOutputPaths: bool(env.YTDLP_MCP_ALLOW_ARBITRARY_OUTPUT_PATHS),
|
|
25
|
+
allowConfigFiles: bool(env.YTDLP_MCP_ALLOW_CONFIG_FILES),
|
|
26
|
+
allowPluginDirs: bool(env.YTDLP_MCP_ALLOW_PLUGIN_DIRS),
|
|
27
|
+
enableExpertMode: bool(env.YTDLP_MCP_ENABLE_EXPERT),
|
|
28
|
+
defaultTimeoutMs: int(env.YTDLP_MCP_TIMEOUT_MS, 15 * 60 * 1000),
|
|
29
|
+
maxOutputBytes: int(env.YTDLP_MCP_MAX_OUTPUT_BYTES, 4 * 1024 * 1024),
|
|
30
|
+
cookiesFile: env.YTDLP_MCP_COOKIES_FILE,
|
|
31
|
+
cookiesFromBrowser: env.YTDLP_MCP_COOKIES_FROM_BROWSER,
|
|
32
|
+
jsRuntimes: (env.YTDLP_MCP_JS_RUNTIMES ?? "deno,node,bun,quickjs").split(",").map((v) => v.trim()).filter(Boolean)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export const CONFIG = loadConfig();
|
|
36
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAmB7B,SAAS,IAAI,CAAC,KAAyB;IACrC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClF,CAAC;AAED,SAAS,GAAG,CAAC,KAAyB,EAAE,QAAgB;IACtD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAA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EAAE,IAAI,CAAC,GAAG,CAAC,4BAA4B,CAAC;QACxD,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC;QACtD,gBAAgB,EAAE,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC;QACnD,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC/D,cAAc,EAAE,GAAG,CAAC,GAAG,CAAC,0BAA0B,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;QACpE,WAAW,EAAE,GAAG,CAAC,sBAAsB;QACvC,kBAAkB,EAAE,GAAG,CAAC,8BAA8B;QACtD,UAAU,EAAE,CAAC,GAAG,CAAC,qBAAqB,IAAI,uBAAuB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;KACnH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ServerConfig } from "./config.js";
|
|
2
|
+
import type { DetectedDependency } from "./types.js";
|
|
3
|
+
export interface EnvironmentReport {
|
|
4
|
+
platform: NodeJS.Platform;
|
|
5
|
+
arch: string;
|
|
6
|
+
node: {
|
|
7
|
+
version: string;
|
|
8
|
+
execPath: string;
|
|
9
|
+
};
|
|
10
|
+
dependencies: DetectedDependency[];
|
|
11
|
+
cookies: {
|
|
12
|
+
fileConfigured: boolean;
|
|
13
|
+
fileExists?: boolean;
|
|
14
|
+
browserConfigured: boolean;
|
|
15
|
+
browser?: string;
|
|
16
|
+
};
|
|
17
|
+
policy: {
|
|
18
|
+
outputRoot: string;
|
|
19
|
+
tempRoot: string;
|
|
20
|
+
allowArbitraryOutputPaths: boolean;
|
|
21
|
+
allowConfigFiles: boolean;
|
|
22
|
+
allowPluginDirs: boolean;
|
|
23
|
+
enableExpertMode: boolean;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare function checkEnvironment(config?: ServerConfig): Promise<EnvironmentReport>;
|
|
27
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,YAAY,EAAE,kBAAkB,EAAE,CAAC;IACnC,OAAO,EAAE;QACP,cAAc,EAAE,OAAO,CAAC;QACxB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,iBAAiB,EAAE,OAAO,CAAC;QAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,yBAAyB,EAAE,OAAO,CAAC;QACnC,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;KAC3B,CAAC;CACH;AAED,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,YAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiChG"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import { CONFIG } from "./config.js";
|
|
4
|
+
import { runCommand } from "./runner.js";
|
|
5
|
+
export async function checkEnvironment(config = CONFIG) {
|
|
6
|
+
const dependencies = await Promise.all([
|
|
7
|
+
detectBinary("yt-dlp", config.ytdlpPath, ["--version"], ["all yt-dlp operations"], true, config),
|
|
8
|
+
detectBinary("ffmpeg", config.ffmpegPath ?? "ffmpeg", ["-version"], ["merge", "remux", "recode", "extract audio", "embed assets"], false, config),
|
|
9
|
+
detectBinary("ffprobe", config.ffprobePath ?? "ffprobe", ["-version"], ["audio extraction", "media probing"], false, config),
|
|
10
|
+
detectBinary("deno", "deno", ["--version"], ["yt-dlp JavaScript challenges"], false, config),
|
|
11
|
+
detectBinary("node", process.execPath, ["--version"], ["yt-dlp JavaScript challenges"], false, config),
|
|
12
|
+
detectBinary("bun", "bun", ["--version"], ["yt-dlp JavaScript challenges"], false, config),
|
|
13
|
+
detectBinary("qjs", "qjs", ["--version"], ["yt-dlp JavaScript challenges"], false, config),
|
|
14
|
+
detectBinary("AtomicParsley", "AtomicParsley", ["--version"], ["legacy thumbnail embedding"], false, config),
|
|
15
|
+
detectBinary("aria2c", "aria2c", ["--version"], ["external downloader"], false, config),
|
|
16
|
+
detectBinary("curl", "curl", ["--version"], ["external downloader"], false, config),
|
|
17
|
+
detectBinary("wget", "wget", ["--version"], ["external downloader"], false, config)
|
|
18
|
+
]);
|
|
19
|
+
return {
|
|
20
|
+
platform: process.platform,
|
|
21
|
+
arch: os.arch(),
|
|
22
|
+
node: {
|
|
23
|
+
version: process.version,
|
|
24
|
+
execPath: process.execPath
|
|
25
|
+
},
|
|
26
|
+
dependencies,
|
|
27
|
+
cookies: cookieStatus(config),
|
|
28
|
+
policy: {
|
|
29
|
+
outputRoot: config.outputRoot,
|
|
30
|
+
tempRoot: config.tempRoot,
|
|
31
|
+
allowArbitraryOutputPaths: config.allowArbitraryOutputPaths,
|
|
32
|
+
allowConfigFiles: config.allowConfigFiles,
|
|
33
|
+
allowPluginDirs: config.allowPluginDirs,
|
|
34
|
+
enableExpertMode: config.enableExpertMode
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function detectBinary(name, command, args, requiredFor, required, config) {
|
|
39
|
+
try {
|
|
40
|
+
const result = await runCommand(command, args, {
|
|
41
|
+
timeoutMs: Math.min(config.defaultTimeoutMs, 10_000),
|
|
42
|
+
maxOutputBytes: 64 * 1024
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
name,
|
|
46
|
+
status: "available",
|
|
47
|
+
command,
|
|
48
|
+
version: firstLine(result.stdout || result.stderr),
|
|
49
|
+
requiredFor,
|
|
50
|
+
notes: required ? [] : ["Optional dependency; required only for matching workflows."]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return {
|
|
55
|
+
name,
|
|
56
|
+
status: "missing",
|
|
57
|
+
command,
|
|
58
|
+
requiredFor,
|
|
59
|
+
notes: [required ? "Required dependency is not available." : "Optional dependency is not available.", error instanceof Error ? error.message : String(error)]
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function cookieStatus(config) {
|
|
64
|
+
const status = {
|
|
65
|
+
fileConfigured: Boolean(config.cookiesFile),
|
|
66
|
+
browserConfigured: Boolean(config.cookiesFromBrowser)
|
|
67
|
+
};
|
|
68
|
+
if (config.cookiesFile)
|
|
69
|
+
status.fileExists = fs.existsSync(config.cookiesFile);
|
|
70
|
+
if (config.cookiesFromBrowser) {
|
|
71
|
+
const browser = config.cookiesFromBrowser.split(":")[0];
|
|
72
|
+
if (browser)
|
|
73
|
+
status.browser = browser;
|
|
74
|
+
}
|
|
75
|
+
return status;
|
|
76
|
+
}
|
|
77
|
+
function firstLine(value) {
|
|
78
|
+
return value.split(/\r?\n/).map((line) => line.trim()).find(Boolean) ?? "";
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environ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IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AAC7E,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAmCjE"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { classifyYtDlpStderr, errorKindMetadata, extractLastError } from "ytdlp-errors";
|
|
2
|
+
import { excerpt } from "./redaction.js";
|
|
3
|
+
import { CommandExecutionError } from "./runner.js";
|
|
4
|
+
export function toStructuredError(error) {
|
|
5
|
+
if (error instanceof CommandExecutionError) {
|
|
6
|
+
const stderr = error.result.stderr || error.result.stdout || error.message;
|
|
7
|
+
const classified = classifyYtDlpStderr(stderr);
|
|
8
|
+
const kind = inferUnsupportedUrl(stderr) ? "unsupportedUrl" : classified.kind;
|
|
9
|
+
const metadata = errorKindMetadata(kind);
|
|
10
|
+
const structured = {
|
|
11
|
+
kind,
|
|
12
|
+
message: extractLastError(stderr) || error.message,
|
|
13
|
+
retryable: metadata.recoverable,
|
|
14
|
+
exitCode: error.result.exitCode,
|
|
15
|
+
stderrExcerpt: excerpt(stderr),
|
|
16
|
+
suggestedFixes: suggestedFixes(kind, metadata.suggestedFlags)
|
|
17
|
+
};
|
|
18
|
+
const dependency = inferDependency(stderr);
|
|
19
|
+
if (dependency)
|
|
20
|
+
structured.dependency = dependency;
|
|
21
|
+
return structured;
|
|
22
|
+
}
|
|
23
|
+
if (error instanceof Error) {
|
|
24
|
+
return {
|
|
25
|
+
kind: "internal",
|
|
26
|
+
message: error.message,
|
|
27
|
+
retryable: false,
|
|
28
|
+
stderrExcerpt: excerpt(error.stack ?? error.message),
|
|
29
|
+
suggestedFixes: []
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
kind: "internal",
|
|
34
|
+
message: String(error),
|
|
35
|
+
retryable: false,
|
|
36
|
+
suggestedFixes: []
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function inferDependency(text) {
|
|
40
|
+
if (/ffmpeg/i.test(text))
|
|
41
|
+
return "ffmpeg";
|
|
42
|
+
if (/ffprobe/i.test(text))
|
|
43
|
+
return "ffprobe";
|
|
44
|
+
if (/atomicparsley/i.test(text))
|
|
45
|
+
return "AtomicParsley";
|
|
46
|
+
if (/aria2c/i.test(text))
|
|
47
|
+
return "aria2c";
|
|
48
|
+
if (/curl_cffi|impersonat/i.test(text))
|
|
49
|
+
return "curl_cffi";
|
|
50
|
+
if (/deno|node|bun|quickjs|javascript/i.test(text))
|
|
51
|
+
return "js-runtime";
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
function inferUnsupportedUrl(text) {
|
|
55
|
+
return /unsupported url|no suitable extractor|not a valid URL/i.test(text);
|
|
56
|
+
}
|
|
57
|
+
function suggestedFixes(kind, flags) {
|
|
58
|
+
const fixes = new Set();
|
|
59
|
+
for (const flag of flags ?? [])
|
|
60
|
+
fixes.add(`Consider ${flag} when appropriate.`);
|
|
61
|
+
if (kind === "missingDependency")
|
|
62
|
+
fixes.add("Install the missing dependency or configure its path with the matching server environment variable.");
|
|
63
|
+
if (kind === "botBlock" || kind === "loginRequired" || kind === "ageRestricted")
|
|
64
|
+
fixes.add("Provide cookies via a cookies file or cookies-from-browser configuration.");
|
|
65
|
+
if (kind === "rateLimit")
|
|
66
|
+
fixes.add("Retry later or add conservative sleep/retry settings.");
|
|
67
|
+
if (kind === "geoBlocked")
|
|
68
|
+
fixes.add("Use an allowed region, proxy, or yt-dlp geo-bypass option where legal.");
|
|
69
|
+
if (kind === "outOfDiskSpace")
|
|
70
|
+
fixes.add("Free disk space or choose a different output root.");
|
|
71
|
+
return [...fixes];
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=errors.js.map
|