From 8df5a5011bb9755a0c13959bb22178313c5500e2 Mon Sep 17 00:00:00 2001 From: Stevie Robinson Date: Fri, 20 Oct 2023 20:48:42 +0200 Subject: [PATCH] Use Diacritical.Net library for NameFirstCharacter token (cherry picked from commit 59ea524e0ce85333779f430b867e93aae366289f) Closes #4230 --- .../FileNameBuilderTests/ArtistNameFirstCharacterFixture.cs | 1 + src/NzbDrone.Core/Lidarr.Core.csproj | 1 + src/NzbDrone.Core/Organizer/FileNameBuilder.cs | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ArtistNameFirstCharacterFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ArtistNameFirstCharacterFixture.cs index 09ec27c41..2db689d61 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ArtistNameFirstCharacterFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ArtistNameFirstCharacterFixture.cs @@ -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) { _artist.Name = title; diff --git a/src/NzbDrone.Core/Lidarr.Core.csproj b/src/NzbDrone.Core/Lidarr.Core.csproj index 7f0bfcd8f..93cfac1d9 100644 --- a/src/NzbDrone.Core/Lidarr.Core.csproj +++ b/src/NzbDrone.Core/Lidarr.Core.csproj @@ -4,6 +4,7 @@ + diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 5b17facb5..36ec1227e 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Text.RegularExpressions; +using Diacritical; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Disk; @@ -268,13 +269,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