Fix auto-rename raw episode folder selection

This commit is contained in:
Sucukdeluxe
2026-03-11 14:17:51 +01:00
parent f9530e015f
commit 99455eca94
2 changed files with 75 additions and 41 deletions
+47 -38
View File
@@ -731,10 +731,10 @@ const SCENE_RP_TOKEN_RE = /(?:^|[._\-\s])rp(?:[._\-\s]|$)/i;
const SCENE_REPACK_TOKEN_RE = /(?:^|[._\-\s])repack(?:[._\-\s]|$)/i;
const SCENE_QUALITY_TOKEN_RE = /([._\-\s])((?:4320|2160|1440|1080|720|576|540|480|360)p)(?=[._\-\s]|$)/i;
const SCENE_GROUP_SUFFIX_FALLBACK_RE = /-([A-Za-z0-9]{2,})$/;
const SCENE_NON_GROUP_SUFFIXES = new Set([
"x264",
"x265",
"h264",
const SCENE_NON_GROUP_SUFFIXES = new Set([
"x264",
"x265",
"h264",
"h265",
"avc",
"hevc",
@@ -745,40 +745,49 @@ const SCENE_NON_GROUP_SUFFIXES = new Set([
"bdrip",
"hdtv",
"dvdrip",
"remux"
]);
function hasSceneGroupSuffix(fileName: string): boolean {
const text = String(fileName || "").trim();
if (!text) {
return false;
}
if (SCENE_GROUP_SUFFIX_RE.test(text)) {
return true;
}
const fallbackMatch = text.match(SCENE_GROUP_SUFFIX_FALLBACK_RE);
const suffix = String(fallbackMatch?.[1] || "").trim();
if (!suffix) {
return false;
}
const lower = suffix.toLowerCase();
if (SCENE_NON_GROUP_SUFFIXES.has(lower)) {
return false;
}
if (/^\d+p$/.test(lower) || /^\d+$/.test(lower)) {
return false;
}
if (/^\d/.test(suffix)) {
return false;
}
if (/4s(?:f|j)/i.test(suffix) && !/^(?:4sf|4sj)$/i.test(suffix)) {
return false;
}
return /[a-z]/i.test(suffix);
}
"remux"
]);
function isValidSceneGroupSuffix(suffix: string): boolean {
const normalizedSuffix = String(suffix || "").trim();
if (!normalizedSuffix) {
return false;
}
const lower = normalizedSuffix.toLowerCase();
if (SCENE_NON_GROUP_SUFFIXES.has(lower)) {
return false;
}
if (/^s\d{1,2}e\d{1,3}(?:e\d{1,3})?$/i.test(normalizedSuffix) || /^s\d{1,2}$/i.test(normalizedSuffix) || /^e\d{1,3}$/i.test(normalizedSuffix)) {
return false;
}
if (/^\d+p$/.test(lower) || /^\d+$/.test(lower)) {
return false;
}
if (/^\d/.test(normalizedSuffix)) {
return false;
}
if (/4s(?:f|j)/i.test(normalizedSuffix) && !/^(?:4sf|4sj)$/i.test(normalizedSuffix)) {
return false;
}
return /[a-z]/i.test(normalizedSuffix);
}
function hasSceneGroupSuffix(fileName: string): boolean {
const text = String(fileName || "").trim();
if (!text) {
return false;
}
if (SCENE_GROUP_SUFFIX_RE.test(text)) {
const directMatch = text.match(SCENE_GROUP_SUFFIX_FALLBACK_RE);
return isValidSceneGroupSuffix(String(directMatch?.[1] || ""));
}
const fallbackMatch = text.match(SCENE_GROUP_SUFFIX_FALLBACK_RE);
const suffix = String(fallbackMatch?.[1] || "").trim();
return isValidSceneGroupSuffix(suffix);
}
export function extractEpisodeToken(fileName: string): string | null {
const text = String(fileName || "");