From 988ba12762605edadf638772a1fc912cfc4c8b72 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 10 Sep 2019 21:47:11 -0400 Subject: [PATCH] Fixed: Cleaning percent signs from release names Co-Authored-By: Mark McDowall --- .../ParserTests/NormalizeTitleFixture.cs | 8 ++++++++ src/NzbDrone.Core/Parser/Parser.cs | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs b/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs index cd42a0737..7634a8fc5 100644 --- a/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs @@ -134,5 +134,13 @@ namespace NzbDrone.Core.Test.ParserTests { "Tokyo Ghoul A".CleanArtistName().Should().Be("tokyoghoula"); } + + [TestCase("3%", "3percent")] + [TestCase("Teen Top & 100% Outing Brothers", "teentop100percentoutingbrothers")] + [TestCase("Big Jay Oakerson's What's Your F@%king Deal?!", "bigjayoakersonswhatsyourfkingdeal")] + public void should_replace_percent_sign_with_percent_following_numbers(string input, string expected) + { + input.CleanArtistName().Should().Be(expected); + } } } diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 54ae26f92..aa72739cb 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -159,6 +159,8 @@ namespace NzbDrone.Core.Parser string.Empty, RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex PercentRegex = new Regex(@"(?<=\b\d+)%", RegexOptions.Compiled); + private static readonly Regex FileExtensionRegex = new Regex(@"\.[a-z0-9]{2,4}$", RegexOptions.IgnoreCase | RegexOptions.Compiled); @@ -479,6 +481,8 @@ namespace NzbDrone.Core.Parser if (long.TryParse(name, out number)) return name; + name = PercentRegex.Replace(name, "percent"); + return NormalizeRegex.Replace(name).ToLower().RemoveAccent(); }