From 07a4c94032fcc8686602cfc7d1acdae170fb0334 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 26 Aug 2011 22:37:20 -0700 Subject: [PATCH] Removed ParseSeasonInfo. ParseEpisodeInfo will mark a report as a full season if no episodes are found, but was matched. Fixed tests that were affected by REGEX changes. --- NzbDrone.Core.Test/IndexerTests.cs | 6 ++-- NzbDrone.Core.Test/ParserTest.cs | 23 +++++------- NzbDrone.Core/Model/EpisodeParseResult.cs | 2 ++ NzbDrone.Core/Parser.cs | 43 ----------------------- 4 files changed, 14 insertions(+), 60 deletions(-) diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 93df7243b..303167f26 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -23,10 +23,10 @@ namespace NzbDrone.Core.Test public class IndexerTests : TestBase { - [TestCase("nzbsorg.xml", 0)] - [TestCase("nzbsrus.xml", 6)] + [TestCase("nzbsorg.xml", 2)] + [TestCase("nzbsrus.xml", 9)] [TestCase("newzbin.xml", 1)] - [TestCase("nzbmatrix.xml", 1)] + [TestCase("nzbmatrix.xml", 2)] public void parse_feed_xml(string fileName, int warns) { var mocker = new AutoMoqer(); diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 665cea1de..479aa3628 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -320,24 +320,19 @@ public void normalize_path_exception_null() Parser.NormalizePath(null); } - [TestCase("Hawaii Five 0 S01E19 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1)] - [TestCase("Chuck.4x05.HDTV.XviD-LOL", "Chuck", 4)] - [TestCase("S03E09 WS PDTV XviD FUtV", "", 3)] - [TestCase("5x10 WS PDTV XviD FUtV", "", 5)] + [TestCase("Hawaii Five 0 S01 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1)] + [TestCase("30 Rock S03 WS PDTV XviD FUtV", "30 Rock", 3)] + [TestCase("The Office Season 4 WS PDTV XviD FUtV", "The Office", 4)] + [TestCase("Eureka Season 1 720p WEB DL DD 5 1 h264 TjHD", "Eureka", 1)] + [TestCase("The Office Season4 WS PDTV XviD FUtV", "The Office", 4)] + [TestCase("Eureka S 01 720p WEB DL DD 5 1 h264 TjHD", "Eureka", 1)] public void parse_season_info(string postTitle, string seriesName, int seasonNumber) { - var result = Parser.ParseSeasonInfo(postTitle); + var result = Parser.ParseTitle(postTitle); - result.SeriesTitle.Should().Be(Parser.NormalizeTitle(seriesName)); + result.CleanTitle.Should().Be(Parser.NormalizeTitle(seriesName)); result.SeasonNumber.Should().Be(seasonNumber); - } - - [Test] - public void parse_season_info_null() - { - var result = Parser.ParseSeasonInfo("This is not a valid post"); - - result.Should().BeNull(); + result.FullSeason.Should().BeTrue(); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Model/EpisodeParseResult.cs b/NzbDrone.Core/Model/EpisodeParseResult.cs index c374cd3ff..4a4fae7b2 100644 --- a/NzbDrone.Core/Model/EpisodeParseResult.cs +++ b/NzbDrone.Core/Model/EpisodeParseResult.cs @@ -28,6 +28,8 @@ public class EpisodeParseResult public String Indexer { get; set; } + public bool FullSeason { get; set; } + public override string ToString() { if (AirDate != null && EpisodeNumbers == null) diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index 1944dff26..5a271c710 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -162,49 +162,6 @@ internal static EpisodeParseResult ParseTitle(string title) return null; } - /// - /// Parses a post title into season it contains - /// - /// Title of the report - /// Season information contained in the post - internal static SeasonParseResult ParseSeasonInfo(string title) - { - Logger.Trace("Parsing string '{0}'", title); - - foreach (var regex in ReportTitleRegex) - { - var match = regex.Matches(title); - - if (match.Count != 0) - { - var seriesName = NormalizeTitle(match[0].Groups["title"].Value); - int year; - Int32.TryParse(match[0].Groups["year"].Value, out year); - - if (year < 1900 || year > DateTime.Now.Year + 1) - { - year = 0; - } - - var seasonNumber = Convert.ToInt32(match[0].Groups["season"].Value); - - var result = new SeasonParseResult - { - SeriesTitle = seriesName, - SeasonNumber = seasonNumber, - Year = year, - Quality = ParseQuality(title) - }; - - - Logger.Trace("Season Parsed. {0}", result); - return result; - } - } - - return null; //Return null - } - /// /// Parses a post title to find the series that relates to it ///