@mkterswingman/yt-mcp 0.1.0 → 0.1.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/dist/tools/remote.js +20 -8
- package/dist/tools/subtitles.js +4 -2
- package/package.json +1 -1
package/dist/tools/remote.js
CHANGED
|
@@ -18,14 +18,25 @@ function createRemoteTool(server, def, tokenManager, apiUrl) {
|
|
|
18
18
|
}
|
|
19
19
|
let res;
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const method = def.method ?? "POST";
|
|
22
|
+
const url = new URL(`${apiUrl}/${def.remotePath}`);
|
|
23
|
+
const headers = {
|
|
24
|
+
Authorization: `Bearer ${token}`,
|
|
25
|
+
};
|
|
26
|
+
const fetchOptions = { method, headers };
|
|
27
|
+
if (method === "GET") {
|
|
28
|
+
// For GET requests, pass params as query string
|
|
29
|
+
for (const [key, value] of Object.entries(params)) {
|
|
30
|
+
if (value !== undefined && value !== null) {
|
|
31
|
+
url.searchParams.set(key, String(value));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
headers["Content-Type"] = "application/json";
|
|
37
|
+
fetchOptions.body = JSON.stringify(params);
|
|
38
|
+
}
|
|
39
|
+
res = await fetch(url.toString(), fetchOptions);
|
|
29
40
|
}
|
|
30
41
|
catch (err) {
|
|
31
42
|
return toolErr("REMOTE_ERROR", `Network error: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -209,6 +220,7 @@ const REMOTE_TOOLS = [
|
|
|
209
220
|
max_chars: z.number().int().min(500).max(50_000).optional(),
|
|
210
221
|
},
|
|
211
222
|
remotePath: "api/patch-notes",
|
|
223
|
+
method: "GET",
|
|
212
224
|
},
|
|
213
225
|
];
|
|
214
226
|
export function registerRemoteTools(server, config, tokenManager) {
|
package/dist/tools/subtitles.js
CHANGED
|
@@ -95,8 +95,10 @@ async function downloadSubtitle(videoId, lang, format) {
|
|
|
95
95
|
error: result.stderr.slice(0, 500) || `yt-dlp exited with ${result.exitCode}`,
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
// Find the output file - yt-dlp appends lang and format extension
|
|
99
|
-
|
|
98
|
+
// Find the output file - yt-dlp appends lang and format extension.
|
|
99
|
+
// For CSV: yt-dlp downloads as VTT first, so only search for VTT (not stale .csv from previous runs).
|
|
100
|
+
const searchFormat = format === "csv" ? "vtt" : format;
|
|
101
|
+
const possibleExts = [`${lang}.${searchFormat}`, `${lang}.vtt`, `${lang}.srt`, `${lang}.ttml`, `${lang}.srv3`];
|
|
100
102
|
let foundFile;
|
|
101
103
|
for (const ext of possibleExts) {
|
|
102
104
|
const candidate = `${outTemplate}.${ext}`;
|