Fixed: Improve parsing of some episodes using day-month-year format

This commit is contained in:
Bogdan 2025-02-19 05:23:05 +02:00 committed by GitHub
parent a2670a5804
commit 5d16169e52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 11 deletions

View file

@ -35,8 +35,7 @@ public class DailyEpisodeParserFixture : CoreTest
[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 @@ public void should_fail_if_episode_is_far_in_future()
}
[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();

View file

@ -1191,14 +1191,12 @@ private static ParsedEpisodeInfo ParseMatchCollection(MatchCollection matchColle
{
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;