trash_list_custom_formats
List custom formats from TRaSH Guides for Radarr or Sonarr, with optional category filtering by HDR, audio, resolution, and more.
Instructions
List available TRaSH Guides custom formats. Can filter by category: hdr, audio, resolution, source, streaming, anime, unwanted, release, language
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| service | Yes | Which service | |
| category | No | Optional filter by category |
Implementation Reference
- src/index.ts:789-807 (schema)Tool registration/schema for 'trash_list_custom_formats'. Defines the tool's name, description, and inputSchema (requires service enum 'radarr'/'sonarr', optional category filter).
{ name: "trash_list_custom_formats", description: "List available TRaSH Guides custom formats. Can filter by category: hdr, audio, resolution, source, streaming, anime, unwanted, release, language", inputSchema: { type: "object" as const, properties: { service: { type: "string", enum: ["radarr", "sonarr"], description: "Which service", }, category: { type: "string", description: "Optional filter by category", }, }, required: ["service"], }, }, - src/index.ts:2132-2152 (handler)Handler for the 'trash_list_custom_formats' tool. Extracts service and optional category from args, calls trashClient.listCustomFormats(service, category), and returns formatted JSON with count, formats (up to 50), available categories.
case "trash_list_custom_formats": { const { service, category } = args as { service: TrashService; category?: string }; const formats = await trashClient.listCustomFormats(service, category); return { content: [{ type: "text", text: JSON.stringify({ service, category: category || 'all', count: formats.length, formats: formats.slice(0, 50).map(f => ({ name: f.name, categories: f.categories, defaultScore: f.defaultScore, })), note: formats.length > 50 ? `Showing first 50 of ${formats.length}. Use category filter to narrow results.` : undefined, availableCategories: ['hdr', 'audio', 'resolution', 'source', 'streaming', 'anime', 'unwanted', 'release', 'language'], }, null, 2), }], }; } - src/trash-client.ts:278-314 (helper)The 'listCustomFormats' method on TrashClient. Fetches CF names from GitHub (cached), fetches each custom format's details in batches of 20, categorizes them via categorizeCustomFormat(), and optionally filters by category. Returns name, categories, and defaultScore for each format.
async listCustomFormats(service: TrashService, category?: string): Promise<{ name: string; categories: string[]; defaultScore?: number }[]> { // Check cache let cfNames = cache.getCFList(service); if (!cfNames) { cfNames = await listGitHubDir(`${service}/cf`); cache.setCFList(service, cfNames); } // Fetch details for categorization const formats: { name: string; categories: string[]; defaultScore?: number }[] = []; // Batch fetch - limit to prevent rate limiting const batchSize = 20; for (let i = 0; i < cfNames.length; i += batchSize) { const batch = cfNames.slice(i, i + batchSize); const results = await Promise.all( batch.map(async name => { const cf = await this.getCustomFormat(service, name); if (!cf) return null; const cats = categorizeCustomFormat(cf.name); return { name: cf.name, categories: cats, defaultScore: cf.trash_scores?.default, }; }) ); formats.push(...results.filter((f): f is NonNullable<typeof f> => f !== null)); } // Filter by category if specified if (category) { return formats.filter(f => f.categories.includes(category.toLowerCase())); } return formats; } - src/trash-client.ts:193-201 (helper)The 'categorizeCustomFormat' helper function. Takes a CF name and returns matching categories (hdr, audio, resolution, source, streaming, anime, unwanted, release, language) based on regex patterns defined in CF_CATEGORIES.
function categorizeCustomFormat(name: string): string[] { const categories: string[] = []; for (const [category, patterns] of Object.entries(CF_CATEGORIES)) { if (patterns.some(p => p.test(name))) { categories.push(category); } } return categories.length > 0 ? categories : ['other']; } - src/trash-client.ts:181-191 (helper)The CF_CATEGORIES constant defining regex patterns used to categorize custom formats into buckets like hdr, audio, resolution, source, streaming, anime, unwanted, release, language.
const CF_CATEGORIES: Record<string, RegExp[]> = { hdr: [/hdr/i, /dv/i, /dolby.*vision/i, /hdr10/i], audio: [/atmos/i, /dts/i, /truehd/i, /audio/i, /surround/i, /sound/i, /stereo/i, /mono/i, /aac/i, /flac/i], resolution: [/1080p/i, /2160p/i, /720p/i, /4k/i, /480p/i], source: [/bluray/i, /web/i, /remux/i, /hdtv/i, /dvd/i, /cam/i, /telesync/i], streaming: [/amzn/i, /nf\b/i, /netflix/i, /dsnp/i, /disney/i, /atvp/i, /apple/i, /hmax/i, /hbo/i, /hulu/i, /pcok/i, /peacock/i], anime: [/anime/i], unwanted: [/lq/i, /x265.*hdtv/i, /extras/i, /3d/i, /upscale/i, /bad.*dual/i], release: [/repack/i, /proper/i, /scene/i, /p2p/i], language: [/french/i, /german/i, /dutch/i, /multi/i, /language/i], };