mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 04:51:45 +02:00
Fixed: TitleThe Naming Token Handling (and tests)
This commit is contained in:
@@ -64,6 +64,8 @@ namespace NzbDrone.Core.Organizer
|
||||
|
||||
private static readonly char[] EpisodeTitleTrimCharacters = new[] { ' ', '.', '?' };
|
||||
|
||||
private static readonly Regex TitlePrefixRegex = new Regex(@"^(The|An|A) (.*?)((?: *\([^)]+\))*)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public FileNameBuilder(INamingConfigService namingConfigService,
|
||||
IQualityDefinitionService qualityDefinitionService,
|
||||
IUpdateMediaInfo mediaInfoUpdater,
|
||||
@@ -167,24 +169,7 @@ namespace NzbDrone.Core.Organizer
|
||||
|
||||
public static string TitleThe(string title)
|
||||
{
|
||||
string[] prefixes = { "The ", "An ", "A " };
|
||||
|
||||
if (title.Length < 5)
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
foreach (string prefix in prefixes)
|
||||
{
|
||||
int prefix_length = prefix.Length;
|
||||
if (prefix.ToLower() == title.Substring(0, prefix_length).ToLower())
|
||||
{
|
||||
title = title.Substring(prefix_length) + ", " + prefix.Trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return title.Trim();
|
||||
return TitlePrefixRegex.Replace(title, "$2, $1$3");
|
||||
}
|
||||
|
||||
public static string CleanFileName(string name, bool replace = true, ColonReplacementFormat colonReplacement = ColonReplacementFormat.Delete)
|
||||
|
Reference in New Issue
Block a user