feat: expand API coverage with new tools, params, and 90% test threshold

This commit is contained in:
Deivid Soto 2026-02-12 15:45:08 +01:00
parent 8bb8e5507e
commit fa913d1561
21 changed files with 1573 additions and 88 deletions

View file

@ -42,13 +42,42 @@ function formatTorrent(t: TorrentInfo, compact?: boolean): string {
let line = ` - ${label} (${size}) | ${seeds}`;
if (score) line += ` | ${score}`;
if (t.season != null) {
const ep =
t.episode != null ? `E${String(t.episode).padStart(2, "0")}` : "";
line += ` | S${String(t.season).padStart(2, "0")}${ep}`;
}
line += `\n Info hash: ${t.infoHash}`;
if (compact) {
// Short magnet (hash only, no trackers) — still clickable, saves ~200 chars per torrent
line += `\n Magnet: magnet:?xt=urn:btih:${t.infoHash}`;
} else if (t.magnetUrl) {
line += `\n Magnet: ${t.magnetUrl}`;
}
if (t.torrentUrl) {
line += `\n Torrent: ${t.torrentUrl}`;
}
// Audio/subtitle track summary (from scanned torrents)
if (t.audioTracks && t.audioTracks.length > 0) {
const langs = t.audioTracks
.map((a) => a.lang || "?")
.filter((v, i, arr) => arr.indexOf(v) === i);
line += `\n Audio: ${langs.join(", ")}`;
const codecs = t.audioTracks
.map((a) => a.codec)
.filter((v): v is string => v != null)
.filter((v, i, arr) => arr.indexOf(v) === i);
if (codecs.length > 0) line += ` (${codecs.join(", ")})`;
}
if (t.subtitleTracks && t.subtitleTracks.length > 0) {
const langs = t.subtitleTracks
.map((s) => s.lang || "?")
.filter((v, i, arr) => arr.indexOf(v) === i);
line += `\n Subtitles: ${langs.join(", ")}`;
}
return line;
}
@ -99,6 +128,7 @@ function formatResult(
` Content ID: ${r.id} — use with get_watch_providers(content_id=${r.id}) or get_credits(content_id=${r.id})`,
);
if (r.imdbId) lines.push(` IMDb: ${r.imdbId}`);
if (r.contentUrl) lines.push(` URL: ${r.contentUrl}`);
return lines.join("\n");
}
@ -111,9 +141,21 @@ export function formatSearchResults(
return "No results found. Try: (1) a shorter or alternate title, (2) removing filters like quality or year, (3) checking spelling. You can also try get_popular or get_recent to browse available content.";
}
const header = `Found ${data.total} results (page ${data.page}, showing ${data.results.length}):`;
const headerParts = [
`Found ${data.total} results (page ${data.page}, showing ${data.results.length}):`,
];
if (data.parsedSeason != null) {
const ep =
data.parsedEpisode != null
? `E${String(data.parsedEpisode).padStart(2, "0")}`
: "";
headerParts.push(
`Detected season/episode: S${String(data.parsedSeason).padStart(2, "0")}${ep}`,
);
}
const results = data.results.map((r, i) => formatResult(r, i + 1, opts));
return [header, "", ...results].join("\n");
return [...headerParts, "", ...results].join("\n");
}
function formatPopularItem(item: PopularItem, index: number): string {