mirror of
https://github.com/Radarr/Radarr.git
synced 2024-10-03 22:57:18 +02:00
Fixed: Cleanup First Character in Title when using 'TitleFirstCharacter'
(cherry picked from commit b3c691859a0841cde9bb2655c01c240cc5279d74) Closes #9249
This commit is contained in:
parent
60d2df043b
commit
3e8cbc497e
@ -37,6 +37,11 @@ public void Setup()
|
||||
[TestCase("The Mist", "M", "The Mist")]
|
||||
[TestCase("A", "A", "A")]
|
||||
[TestCase("30 Rock", "3", "30 Rock")]
|
||||
[TestCase("The '80s Greatest", "8", "The '80s Greatest")]
|
||||
[TestCase("좀비버스", "좀", "좀비버스")]
|
||||
[TestCase("¡Mucha Lucha!", "M", "¡Mucha Lucha!")]
|
||||
[TestCase(".hack", "H", "hack")]
|
||||
[TestCase("Ütopya", "U", "Ütopya")]
|
||||
public void should_get_expected_folder_name_back(string title, string parent, string child)
|
||||
{
|
||||
_movie.Title = title;
|
||||
|
@ -220,6 +220,23 @@ public static string TitleThe(string title)
|
||||
return TitlePrefixRegex.Replace(title, "$2, $1$3");
|
||||
}
|
||||
|
||||
public static string TitleFirstCharacter(string title)
|
||||
{
|
||||
if (char.IsLetterOrDigit(title[0]))
|
||||
{
|
||||
return title.Substring(0, 1).ToUpper().RemoveAccent();
|
||||
}
|
||||
|
||||
// Try the second character if the first was non alphanumeric
|
||||
if (char.IsLetterOrDigit(title[1]))
|
||||
{
|
||||
return title.Substring(1, 1).ToUpper().RemoveAccent();
|
||||
}
|
||||
|
||||
// Default to "_" if no alphanumeric character can be found in the first 2 positions
|
||||
return "_";
|
||||
}
|
||||
|
||||
public static string CleanFileName(string name, bool replace = true, ColonReplacementFormat colonReplacement = ColonReplacementFormat.Delete)
|
||||
{
|
||||
var colonReplacementFormat = colonReplacement.GetFormatString();
|
||||
@ -248,7 +265,7 @@ private void AddMovieTokens(Dictionary<string, Func<TokenMatch, string>> tokenHa
|
||||
tokenHandlers["{Movie Title}"] = m => GetLanguageTitle(movie, m.CustomFormat);
|
||||
tokenHandlers["{Movie CleanTitle}"] = m => CleanTitle(GetLanguageTitle(movie, m.CustomFormat));
|
||||
tokenHandlers["{Movie TitleThe}"] = m => TitleThe(movie.Title);
|
||||
tokenHandlers["{Movie TitleFirstCharacter}"] = m => TitleThe(GetLanguageTitle(movie, m.CustomFormat)).Substring(0, 1).FirstCharToUpper();
|
||||
tokenHandlers["{Movie TitleFirstCharacter}"] = m => TitleFirstCharacter(TitleThe(GetLanguageTitle(movie, m.CustomFormat)));
|
||||
tokenHandlers["{Movie OriginalTitle}"] = m => movie.MovieMetadata.Value.OriginalTitle ?? string.Empty;
|
||||
tokenHandlers["{Movie CleanOriginalTitle}"] = m => CleanTitle(movie.MovieMetadata.Value.OriginalTitle ?? string.Empty);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user