Detect release group after bracketed metadata suffix
Naming-bot style releases like:
Family Guy (1999) - S22E15 - Faith No More [HULU WEBDL-1080p]
[EAC3 5.1][h264]-NTb
tack the group on with a dash right after the last metadata bracket,
rather than as a bare word ("x264-Group") or inside a trailing
parenthetical. FileSuffixTagRegex only matched the bare-word case, so
this pattern fell through untouched.
Added FileSuffixBracketDashTagRegex to catch "[bracket]-Group" at the
end of the stem, guarded by IsMetadataBracket on the bracket contents
so an ordinary hyphenated word after an unrelated bracket (e.g.
"[Interview]-Style") is never mistaken for a group suffix.
This commit is contained in:
+2
-2
@@ -9,8 +9,8 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<AssemblyName>Futonizer</AssemblyName>
|
<AssemblyName>Futonizer</AssemblyName>
|
||||||
<RootNamespace>Futonizer</RootNamespace>
|
<RootNamespace>Futonizer</RootNamespace>
|
||||||
<Version>1.0.11</Version>
|
<Version>1.0.12</Version>
|
||||||
<FileVersion>1.0.11.0</FileVersion>
|
<FileVersion>1.0.12.0</FileVersion>
|
||||||
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,16 @@ public static class FileNameHelper
|
|||||||
private static readonly Regex FileSuffixTagRegex =
|
private static readonly Regex FileSuffixTagRegex =
|
||||||
new(@"(?:^|[\s.])([A-Za-z0-9]+)-([A-Za-z][A-Za-z0-9]{2,20})$", RegexOptions.Compiled);
|
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
|
// Trailing parenthesised metadata block ending in the release group as its
|
||||||
// last word, e.g. "... (1080p AMZN WEB-DL x265 Celdra)" → group="Celdra".
|
// 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
|
// Common on Amazon/streaming rips that don't set the group off with a
|
||||||
@@ -87,10 +97,12 @@ public static class FileNameHelper
|
|||||||
/// (in order):
|
/// (in order):
|
||||||
/// <list type="number">
|
/// <list type="number">
|
||||||
/// <item>Filename suffix tag extraction — a trailing <c>-GroupName</c> on
|
/// <item>Filename suffix tag extraction — a trailing <c>-GroupName</c> on
|
||||||
/// the filename stem, or a release group tucked in as the last word
|
/// the filename stem, a group tacked on after a bracketed metadata
|
||||||
/// of a trailing <c>(...)</c> metadata block (e.g. Amazon rips like
|
/// block (e.g. <c>[h264]-NTb</c>), or a release group tucked in as
|
||||||
/// <c>(1080p AMZN WEB-DL x265 Celdra)</c>), is stripped and promoted
|
/// the last word of a trailing <c>(...)</c> metadata block (e.g.
|
||||||
/// to a bracket prefix. Takes priority over any folder-derived tag.</item>
|
/// Amazon rips like <c>(1080p AMZN WEB-DL x265 Celdra)</c>), is
|
||||||
|
/// stripped and promoted to a bracket prefix. Takes priority over
|
||||||
|
/// any folder-derived tag.</item>
|
||||||
/// <item>Show-name injection — if the (now tag-free) filename starts with
|
/// <item>Show-name injection — if the (now tag-free) filename starts with
|
||||||
/// an episode code (e.g. S01E01) the show name is derived from the
|
/// an episode code (e.g. S01E01) the show name is derived from the
|
||||||
/// parent folder and prepended.</item>
|
/// parent folder and prepended.</item>
|
||||||
@@ -121,6 +133,7 @@ public static class FileNameHelper
|
|||||||
// hyphenated title words are left alone.
|
// hyphenated title words are left alone.
|
||||||
string? fileTag = null;
|
string? fileTag = null;
|
||||||
var fileSuffixMatch = FileSuffixTagRegex.Match(stemNoExt);
|
var fileSuffixMatch = FileSuffixTagRegex.Match(stemNoExt);
|
||||||
|
var bracketDashMatch = FileSuffixBracketDashTagRegex.Match(stemNoExt);
|
||||||
if (fileSuffixMatch.Success
|
if (fileSuffixMatch.Success
|
||||||
&& IsMetadataToken(fileSuffixMatch.Groups[1].Value)
|
&& IsMetadataToken(fileSuffixMatch.Groups[1].Value)
|
||||||
&& !IsMetadataToken(fileSuffixMatch.Groups[2].Value))
|
&& !IsMetadataToken(fileSuffixMatch.Groups[2].Value))
|
||||||
@@ -129,6 +142,16 @@ public static class FileNameHelper
|
|||||||
stemNoExt = stemNoExt[..(fileSuffixMatch.Groups[2].Index - 1)];
|
stemNoExt = stemNoExt[..(fileSuffixMatch.Groups[2].Index - 1)];
|
||||||
fileName = stemNoExt + ext;
|
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
|
else
|
||||||
{
|
{
|
||||||
// 1b. Extract a release group tucked in as the last word of a
|
// 1b. Extract a release group tucked in as the last word of a
|
||||||
|
|||||||
Reference in New Issue
Block a user