Use Diacritical.Net library for TitleFirstCharacter token

(cherry picked from commit 59ea524e0ce85333779f430b867e93aae366289f)

Closes #9324
This commit is contained in:
Stevie Robinson 2023-10-20 20:48:42 +02:00 committed by Bogdan
parent 3e8cbc497e
commit 7bbdcc81bb
3 changed files with 6 additions and 2 deletions

View File

@ -42,6 +42,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
[TestCase("¡Mucha Lucha!", "M", "¡Mucha Lucha!")]
[TestCase(".hack", "H", "hack")]
[TestCase("Ütopya", "U", "Ütopya")]
[TestCase("Æon Flux", "A", "Æon Flux")]
public void should_get_expected_folder_name_back(string title, string parent, string child)
{
_movie.Title = title;

View File

@ -5,6 +5,8 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Diacritical;
using DryIoc.ImTools;
using NLog;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.Extensions;
@ -224,13 +226,13 @@ namespace NzbDrone.Core.Organizer
{
if (char.IsLetterOrDigit(title[0]))
{
return title.Substring(0, 1).ToUpper().RemoveAccent();
return title.Substring(0, 1).ToUpper().RemoveDiacritics()[0].ToString();
}
// Try the second character if the first was non alphanumeric
if (char.IsLetterOrDigit(title[1]))
{
return title.Substring(1, 1).ToUpper().RemoveAccent();
return title.Substring(1, 1).ToUpper().RemoveDiacritics()[0].ToString();
}
// Default to "_" if no alphanumeric character can be found in the first 2 positions

View File

@ -4,6 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.143" />
<PackageReference Include="Diacritical.Net" Version="1.0.4" />
<PackageReference Include="Equ" Version="2.3.0" />
<PackageReference Include="MailKit" Version="3.6.0" />
<PackageReference Include="Npgsql" Version="7.0.4" />