From a9171d44d9e596ab882c2d7fecb8b9f0985e9882 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 12 Dec 2014 15:49:32 -0800 Subject: [PATCH] Sorting for another show that starts with A --- .../TvTests/SeriesTitleNormalizerFixture.cs | 7 ++++--- src/NzbDrone.Core/Parser/Parser.cs | 8 ++++---- src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesTitleNormalizerFixture.cs b/src/NzbDrone.Core.Test/TvTests/SeriesTitleNormalizerFixture.cs index e8af79cbf..7ce588270 100644 --- a/src/NzbDrone.Core.Test/TvTests/SeriesTitleNormalizerFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/SeriesTitleNormalizerFixture.cs @@ -8,10 +8,11 @@ namespace NzbDrone.Core.Test.TvTests [TestFixture] public class SeriesTitleNormalizerFixture { - [Test] - public void should_use_precomputed_title_for_a_to_z() + [TestCase("A to Z", 281588, "a to z")] + [TestCase("A. D. - The Trials & Triumph of the Early Church", 266757, "ad trials triumph early church")] + public void should_use_precomputed_title(string title, int tvdbId, string expected) { - SeriesTitleNormalizer.Normalize("A to Z", 281588).Should().Be("a to z"); + SeriesTitleNormalizer.Normalize(title, tvdbId).Should().Be(expected); } [TestCase("2 Broke Girls", "2 broke girls")] diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 42f8f205f..9da02a071 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -169,10 +169,9 @@ namespace NzbDrone.Core.Parser private static readonly Regex WordDelimiterRegex = new Regex(@"(\s|\.|,|_|-|=|\|)+", RegexOptions.Compiled); private static readonly Regex PunctuationRegex = new Regex(@"[^\w\s]", RegexOptions.Compiled); - private static readonly Regex CommonWordRegex = new Regex(@"\b(a|an|the|and|or|of)\b\s?", - RegexOptions.IgnoreCase | RegexOptions.Compiled); - private static readonly Regex SpecialEpisodeWordRegex = new Regex(@"\b(part|special|edition)\b\s?", - RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex CommonWordRegex = new Regex(@"\b(a|an|the|and|or|of)\b\s?", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex SpecialEpisodeWordRegex = new Regex(@"\b(part|special|edition)\b\s?", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex DuplicateSpacesRegex = new Regex(@"\s{2,}", RegexOptions.Compiled); private static readonly Regex RequestInfoRegex = new Regex(@"\[.+?\]", RegexOptions.Compiled); @@ -347,6 +346,7 @@ namespace NzbDrone.Core.Parser title = WordDelimiterRegex.Replace(title, " "); title = PunctuationRegex.Replace(title, String.Empty); title = CommonWordRegex.Replace(title, String.Empty); + title = DuplicateSpacesRegex.Replace(title, " "); return title.Trim().ToLower(); } diff --git a/src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs b/src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs index 532d60ea6..f6bbdfa31 100644 --- a/src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs +++ b/src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs @@ -7,7 +7,8 @@ namespace NzbDrone.Core.Tv { private readonly static Dictionary PreComputedTitles = new Dictionary { - { 281588, "a to z" } + { 281588, "a to z" }, + { 266757, "ad trials triumph early church" } }; public static String Normalize(String title, Int32 tvdbId)