Fix auto-rename episode range folders producing duplicate MKV names
Folder names with episode ranges like S01E01-E08 (common in season packs from debrid servers) were returned unchanged as target name, causing all episodes to get the same filename and producing (2)(3)(4) suffixes during MKV collection. - Detect episode ranges (S01E01-E08, S01E01-08) in folder names and replace them with the source file's specific episode token - Extend applyEpisodeTokenToFolderName regex to match and replace full episode ranges instead of only single episode tokens Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
15ed49e783
commit
7b764be769
@ -1012,7 +1012,10 @@ export function applyEpisodeTokenToFolderName(folderName: string, episodeToken:
|
|||||||
return episodeToken;
|
return episodeToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
const episodeRe = /(^|[._\-\s])s\d{1,2}e\d{1,3}(?:e\d{1,3})?(?=[._\-\s]|$)/i;
|
// Match single episodes (S01E03), multi-episodes (S01E01E02), and
|
||||||
|
// episode ranges (S01E01-E08, S01E01-08) so the range is fully replaced
|
||||||
|
// with the source's specific episode token.
|
||||||
|
const episodeRe = /(^|[._\-\s])s\d{1,2}e\d{1,3}(?:e\d{1,3})?(?:[-]e?\d{1,3})?(?=[._\-\s]|$)/i;
|
||||||
if (episodeRe.test(trimmed)) {
|
if (episodeRe.test(trimmed)) {
|
||||||
return trimmed.replace(episodeRe, `$1${episodeToken}`);
|
return trimmed.replace(episodeRe, `$1${episodeToken}`);
|
||||||
}
|
}
|
||||||
@ -1085,6 +1088,17 @@ export function buildAutoRenameBaseName(folderName: string, sourceFileName: stri
|
|||||||
? applyEpisodeTokenToFolderName(normalizedFolderName, episodeToken)
|
? applyEpisodeTokenToFolderName(normalizedFolderName, episodeToken)
|
||||||
: normalizedFolderName;
|
: normalizedFolderName;
|
||||||
|
|
||||||
|
// If the folder contains an episode RANGE (e.g. S01E01-E08), replace the
|
||||||
|
// range with the source's specific episode token. Without this, all
|
||||||
|
// episodes in a range-named folder share the same target name, producing
|
||||||
|
// (2)(3)(4) suffixes during MKV collection.
|
||||||
|
if (!isLegacy4sf4sjFolder && isSceneGroupFolder) {
|
||||||
|
const episodeRangeRe = /(^|[._\-\s])s\d{1,2}e\d{1,3}[-]e?\d{1,3}(?=[._\-\s]|$)/i;
|
||||||
|
if (episodeRangeRe.test(normalizedFolderName)) {
|
||||||
|
next = applyEpisodeTokenToFolderName(normalizedFolderName, episodeToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const hasRepackHint = sourceHasRpToken(normalizedSourceFileName)
|
const hasRepackHint = sourceHasRpToken(normalizedSourceFileName)
|
||||||
|| SCENE_REPACK_TOKEN_RE.test(normalizedSourceFileName)
|
|| SCENE_REPACK_TOKEN_RE.test(normalizedSourceFileName)
|
||||||
|| sourceHasRpToken(normalizedFolderName)
|
|| sourceHasRpToken(normalizedFolderName)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user