From 7bbdcc81bb68bf4f46ea1103cb39a34a53bc7509 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 TitleFirstCharacter token (cherry picked from commit 59ea524e0ce85333779f430b867e93aae366289f) Closes #9324 --- .../FileNameBuilderTests/MovieTitleFirstCharacterFixture.cs | 1 + src/NzbDrone.Core/Organizer/FileNameBuilder.cs | 6 ++++-- src/NzbDrone.Core/Radarr.Core.csproj | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MovieTitleFirstCharacterFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MovieTitleFirstCharacterFixture.cs index 23fd6754a8..6e936063a6 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MovieTitleFirstCharacterFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MovieTitleFirstCharacterFixture.cs @@ -42,6 +42,7 @@ public void Setup() [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; diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 8f33e3c893..651744a859 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -5,6 +5,8 @@ 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 @@ public static string TitleFirstCharacter(string title) { 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 diff --git a/src/NzbDrone.Core/Radarr.Core.csproj b/src/NzbDrone.Core/Radarr.Core.csproj index a0af5e095d..bbe96d23da 100644 --- a/src/NzbDrone.Core/Radarr.Core.csproj +++ b/src/NzbDrone.Core/Radarr.Core.csproj @@ -4,6 +4,7 @@ +