Fixed: Cleanup First Character in Title when using 'TitleFirstCharacter'
Closes #6055
This commit is contained in:
parent
bfaa7291e1
commit
b3c691859a
|
@ -36,6 +36,12 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
|||
[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 expected)
|
||||
{
|
||||
_series.Title = title;
|
||||
|
|
|
@ -377,6 +377,23 @@ namespace NzbDrone.Core.Organizer
|
|||
return title;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return CleanFileName(name, NamingConfig.Default);
|
||||
|
@ -452,7 +469,7 @@ namespace NzbDrone.Core.Organizer
|
|||
tokenHandlers["{Series TitleWithoutYear}"] = m => TitleWithoutYear(series.Title);
|
||||
tokenHandlers["{Series TitleTheYear}"] = m => TitleYear(TitleThe(series.Title), series.Year);
|
||||
tokenHandlers["{Series TitleTheWithoutYear}"] = m => TitleWithoutYear(TitleThe(series.Title));
|
||||
tokenHandlers["{Series TitleFirstCharacter}"] = m => TitleThe(series.Title).Substring(0, 1).FirstCharToUpper();
|
||||
tokenHandlers["{Series TitleFirstCharacter}"] = m => TitleFirstCharacter(TitleThe(series.Title));
|
||||
tokenHandlers["{Series Year}"] = m => series.Year.ToString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue