From 96317b476c9768fb38a6ef06b693a2ff0a8a6517 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 23 Feb 2012 23:31:15 -0800 Subject: [PATCH] Fixed: Parsing of daily episodes with bad date format (YYYY/DD/MM) instead of (YYYY/MM/DD) --- NzbDrone.Core.Test/ParserTest.cs | 4 ++++ NzbDrone.Core/Parser.cs | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 1053e7653..59ebf3eea 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -209,10 +209,14 @@ namespace NzbDrone.Core.Test [TestCase("2011.01.10 - Denis Leary - HD TV.mkv", "", 2011, 1, 10)] [TestCase("2011.03.13 - Denis Leary - HD TV.mkv", "", 2011, 3, 13)] [TestCase("The Tonight Show with Jay Leno - 2011-06-16 - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo", "The Tonight Show with Jay Leno", 2011, 6, 16)] + [TestCase("2020.NZ.2012.16.02.PDTV.XviD-C4TV","2020nz", 2012,2, 16)] + [TestCase("2020.NZ.2012.13.02.PDTV.XviD-C4TV","2020nz", 2012,2, 13)] + [TestCase("2020.NZ.2011.12.02.PDTV.XviD-C4TV","2020nz", 2011,12, 2)] public void parse_daily_episodes(string postTitle, string title, int year, int month, int day) { var result = Parser.ParseTitle(postTitle); var airDate = new DateTime(year, month, day); + result.Should().NotBeNull(); result.CleanTitle.Should().Be(Parser.NormalizeTitle(title)); result.AirDate.Should().Be(airDate); result.EpisodeNumbers.Should().BeNull(); diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index 5324bf8fb..d616f0b46 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -192,8 +192,17 @@ namespace NzbDrone.Core var airmonth = Convert.ToInt32(matchCollection[0].Groups["airmonth"].Value); var airday = Convert.ToInt32(matchCollection[0].Groups["airday"].Value); + //Swap day and month if month is bigger than 12 (scene fail) + if (airmonth > 12) + { + var tempDay = airday; + airday = airmonth; + airmonth = tempDay; + } + parsedEpisode = new EpisodeParseResult { + AirDate = new DateTime(airyear, airmonth, airday).Date, }; }