From 5d16169e52359a5ac5ff5fd1a098d75bc1926f4d Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 19 Feb 2025 05:23:05 +0200 Subject: [PATCH] Fixed: Improve parsing of some episodes using day-month-year format --- .../ParserTests/DailyEpisodeParserFixture.cs | 6 ++---- src/NzbDrone.Core/Parser/Parser.cs | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs index 0611355cb..f21a0f47d 100644 --- a/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs @@ -35,8 +35,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Series Title (1955) - 1954-01-23 05 00 00 - Cottage for Sale.ts", "Series Title (1955)", 1954, 1, 23)] [TestCase("Series Title - 30-04-2024 HDTV 1080p H264 AAC", "Series Title", 2024, 4, 30)] [TestCase("Series On TitleClub E76 2024 08 08 1080p WEB H264-RnB96 [TJET]", "Series On TitleClub", 2024, 8, 8)] - - // [TestCase("", "", 0, 0, 0)] + [TestCase("Series.Title.13.02.2025.1080i.HDTV.MPA2.0.H.264", "Series Title", 2025, 2, 13)] public void should_parse_daily_episode(string postTitle, string title, int year, int month, int day) { var result = Parser.Parser.ParseTitle(postTitle); @@ -104,8 +103,7 @@ namespace NzbDrone.Core.Test.ParserTests } [TestCase("Tmc - Quotidien - 05-06-2024 HDTV 1080p H264 AAC")] - - // [TestCase("", "", 0, 0, 0)] + [TestCase("Series.Title.12.02.2025.1080i.HDTV.MPA2.0.H.264")] public void should_not_parse_ambiguous_daily_episode(string postTitle) { Parser.Parser.ParseTitle(postTitle).Should().BeNull(); diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index cde70ba88..0a06f8f38 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -1191,14 +1191,12 @@ namespace NzbDrone.Core.Parser { airmonth = Convert.ToInt32(matchCollection[0].Groups["airmonth"].Value); 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; - } + // Swap day and month if month is bigger than 12 (scene fail) + if (airmonth > 12) + { + (airday, airmonth) = (airmonth, airday); } DateTime airDate;