From b9eab860f5970da182ebec7cb22906ccdf41d71e Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Wed, 8 Mar 2017 19:10:04 +0100 Subject: [PATCH] Fixed the parser for movies with A. Fixes some parser issues. --- .../ParserTests/ParserFixture.cs | 3 +++ src/NzbDrone.Core/Parser/Parser.cs | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 51eb510a8..8a509d9fd 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -71,6 +71,9 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("This Is A Movie (1999) [IMDB #] {ACTORS} !DIRECTOR +MORE_SILLY_STUFF_NO_ONE_NEEDS ?", "This Is A Movie")] [TestCase("We Are the Best!.2013.720p.H264.mkv", "We Are the Best!")] [TestCase("(500).Days.Of.Summer.(2009).DTS.1080p.BluRay.x264.NLsubs", "(500) Days Of Summer")] + [TestCase("To.Live.and.Die.in.L.A.1985.1080p.BluRay", "To Live and Die in L.A.")] + [TestCase("A.I.Artificial.Intelligence.(2001)", "A.I. Artificial Intelligence")] + [TestCase("A.Movie.Name.(1998)", "A Movie Name")] public void should_parse_movie_title(string postTitle, string title) { Parser.Parser.ParseMovieTitle(postTitle).MovieTitle.Should().Be(title); diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 1f46ecb18..d56d241a6 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -736,15 +736,25 @@ namespace NzbDrone.Core.Parser var parts = seriesName.Split('.'); seriesName = ""; - int n; + int n = 0; bool previousAcronym = false; + string nextPart = ""; foreach (var part in parts) { + if (parts.Length >= n+2) + { + nextPart = parts[n+1]; + } if (part.Length == 1 && part.ToLower() != "a" && !int.TryParse(part, out n)) { seriesName += part + "."; previousAcronym = true; } + else if (part.ToLower() == "a" && (previousAcronym == true || nextPart.Length == 1)) + { + seriesName += part + "."; + previousAcronym = true; + } else { if (previousAcronym) @@ -754,7 +764,7 @@ namespace NzbDrone.Core.Parser } seriesName += part + " "; } - + n++; } seriesName = seriesName.Trim(' ');