From 06e649ba5b99e4fd6ae905e2ba68b8218d2e5f68 Mon Sep 17 00:00:00 2001 From: Sucukdeluxe Date: Fri, 6 Mar 2026 19:33:15 +0100 Subject: [PATCH] fix: skip sample MKVs during library collection MKV library collection now filters out sample files before moving. Files in "sample"/"samples" directories and files with "sample" in their name are excluded. This prevents duplicate "(2)" entries in the library folder caused by samples having the same base name as the real episodes (just different casing from the archive). Co-Authored-By: Claude Opus 4.6 --- src/main/download-manager.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/download-manager.ts b/src/main/download-manager.ts index 4d951c5..4ee5de8 100644 --- a/src/main/download-manager.ts +++ b/src/main/download-manager.ts @@ -2509,12 +2509,34 @@ export class DownloadManager extends EventEmitter { return; } - const mkvFiles = await this.collectFilesByExtensions(sourceDir, new Set([".mkv"])); - if (mkvFiles.length === 0) { + const allMkvFiles = await this.collectFilesByExtensions(sourceDir, new Set([".mkv"])); + if (allMkvFiles.length === 0) { logger.info(`MKV-Sammelordner: pkg=${pkg.name}, keine MKV gefunden`); return; } + // Filter: Sample-Dateien ausschließen (Sample-Ordner + "sample" im Dateinamen) + const sampleDirNames = new Set(["sample", "samples"]); + const sampleTokenRe = /(^|[._\-\s])sample([._\-\s]|$)/i; + const mkvFiles: string[] = []; + let sampleSkipped = 0; + for (const filePath of allMkvFiles) { + const parentDir = path.basename(path.dirname(filePath)).toLowerCase(); + const stem = path.parse(path.basename(filePath)).name; + if (sampleDirNames.has(parentDir) || sampleTokenRe.test(stem)) { + sampleSkipped += 1; + continue; + } + mkvFiles.push(filePath); + } + if (sampleSkipped > 0) { + logger.info(`MKV-Sammelordner: pkg=${pkg.name}, ${sampleSkipped} Sample-MKV(s) übersprungen`); + } + if (mkvFiles.length === 0) { + logger.info(`MKV-Sammelordner: pkg=${pkg.name}, keine MKV nach Sample-Filter`); + return; + } + const reservedTargets = new Set(); let moved = 0; let skipped = 0;