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 <noreply@anthropic.com>
This commit is contained in:
parent
977a5c4175
commit
06e649ba5b
@ -2509,12 +2509,34 @@ export class DownloadManager extends EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mkvFiles = await this.collectFilesByExtensions(sourceDir, new Set([".mkv"]));
|
const allMkvFiles = await this.collectFilesByExtensions(sourceDir, new Set([".mkv"]));
|
||||||
if (mkvFiles.length === 0) {
|
if (allMkvFiles.length === 0) {
|
||||||
logger.info(`MKV-Sammelordner: pkg=${pkg.name}, keine MKV gefunden`);
|
logger.info(`MKV-Sammelordner: pkg=${pkg.name}, keine MKV gefunden`);
|
||||||
return;
|
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<string>();
|
const reservedTargets = new Set<string>();
|
||||||
let moved = 0;
|
let moved = 0;
|
||||||
let skipped = 0;
|
let skipped = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user