diff --git a/Futonizer.csproj b/Futonizer.csproj index b83777d..c44dbbf 100644 --- a/Futonizer.csproj +++ b/Futonizer.csproj @@ -9,8 +9,8 @@ enable Futonizer Futonizer - 1.0.11 - 1.0.11.0 + 1.0.12 + 1.0.12.0 Assets\app.ico diff --git a/Services/FileNameHelper.cs b/Services/FileNameHelper.cs index 965ef8c..79f600b 100644 --- a/Services/FileNameHelper.cs +++ b/Services/FileNameHelper.cs @@ -30,6 +30,16 @@ public static class FileNameHelper private static readonly Regex FileSuffixTagRegex = new(@"(?:^|[\s.])([A-Za-z0-9]+)-([A-Za-z][A-Za-z0-9]{2,20})$", RegexOptions.Compiled); + // File suffix release tag directly after a bracketed metadata block: + // "...[HULU WEBDL-1080p][EAC3 5.1][h264]-NTb" → tag = "NTb" + // Common on naming-bot-style releases that group tech specs into their + // own brackets and tack the group on with a dash at the very end. The + // bracket immediately before the dash must itself be recognisable + // metadata (checked by the caller via IsMetadataBracket), mirroring + // FileSuffixTagRegex's guard for the bare-word case. + private static readonly Regex FileSuffixBracketDashTagRegex = + new(@"\[([^\[\]]+)\]-([A-Za-z][A-Za-z0-9]{2,20})$", RegexOptions.Compiled); + // Trailing parenthesised metadata block ending in the release group as its // last word, e.g. "... (1080p AMZN WEB-DL x265 Celdra)" → group="Celdra". // Common on Amazon/streaming rips that don't set the group off with a @@ -87,10 +97,12 @@ public static class FileNameHelper /// (in order): /// /// Filename suffix tag extraction — a trailing -GroupName on - /// the filename stem, or a release group tucked in as the last word - /// of a trailing (...) metadata block (e.g. Amazon rips like - /// (1080p AMZN WEB-DL x265 Celdra)), is stripped and promoted - /// to a bracket prefix. Takes priority over any folder-derived tag. + /// the filename stem, a group tacked on after a bracketed metadata + /// block (e.g. [h264]-NTb), or a release group tucked in as + /// the last word of a trailing (...) metadata block (e.g. + /// Amazon rips like (1080p AMZN WEB-DL x265 Celdra)), is + /// stripped and promoted to a bracket prefix. Takes priority over + /// any folder-derived tag. /// Show-name injection — if the (now tag-free) filename starts with /// an episode code (e.g. S01E01) the show name is derived from the /// parent folder and prepended. @@ -121,6 +133,7 @@ public static class FileNameHelper // hyphenated title words are left alone. string? fileTag = null; var fileSuffixMatch = FileSuffixTagRegex.Match(stemNoExt); + var bracketDashMatch = FileSuffixBracketDashTagRegex.Match(stemNoExt); if (fileSuffixMatch.Success && IsMetadataToken(fileSuffixMatch.Groups[1].Value) && !IsMetadataToken(fileSuffixMatch.Groups[2].Value)) @@ -129,6 +142,16 @@ public static class FileNameHelper stemNoExt = stemNoExt[..(fileSuffixMatch.Groups[2].Index - 1)]; fileName = stemNoExt + ext; } + else if (bracketDashMatch.Success + && IsMetadataBracket(bracketDashMatch.Groups[1].Value) + && !IsMetadataToken(bracketDashMatch.Groups[2].Value)) + { + // 1a. Extract a release group tacked on after a bracketed metadata + // block, e.g. "...[h264]-NTb" → tag="NTb", stem="...[h264]". + fileTag = bracketDashMatch.Groups[2].Value; + stemNoExt = stemNoExt[..(bracketDashMatch.Groups[2].Index - 1)]; + fileName = stemNoExt + ext; + } else { // 1b. Extract a release group tucked in as the last word of a