From d0adac0b5d63c9d661f689585362896362f4aca7 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 29 Nov 2013 09:05:52 -0800 Subject: [PATCH] Fixed: Parsing files/releases for series that start with numbers --- src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs | 12 ++++++++---- src/NzbDrone.Core/Parser/Parser.cs | 9 +++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index e68ac3ca9..750a3cafa 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -86,6 +86,9 @@ public class ParserFixture : CoreTest [TestCase("Hostages.S01E04.2-45.PM.[HDTV-720p].mkv", "Hostages", 1, 4)] [TestCase("S01E04", "", 1, 4)] [TestCase("1x04", "", 1, 4)] + [TestCase("10.Things.You.Dont.Know.About.S02E04.Prohibition.HDTV.XviD-AFG", "10 Things You Dont Know About", 2, 4)] + [TestCase("30 Rock - S01E01 - Pilot.avi", "30 Rock", 1, 1)] + [TestCase("666 Park Avenue - S01E01", "666 Park Avenue", 1, 1)] public void ParseTitle_single(string postTitle, string title, int seasonNumber, int episodeNumber) { var result = Parser.Parser.ParseTitle(postTitle); @@ -94,6 +97,7 @@ public void ParseTitle_single(string postTitle, string title, int seasonNumber, result.SeasonNumber.Should().Be(seasonNumber); result.EpisodeNumbers.First().Should().Be(episodeNumber); result.SeriesTitle.Should().Be(title.CleanSeriesTitle()); + result.AbsoluteEpisodeNumbers.Should().BeEmpty(); } [TestCase(@"z:\tv shows\battlestar galactica (2003)\Season 3\S03E05 - Collaborators.mkv", 3, 5)] @@ -193,10 +197,10 @@ public void parse_daily_episodes(string postTitle, string title, int year, int m [TestCase("[K-F] One Piece S10E14 214", "One Piece", 214, 10, 14)] [TestCase("[K-F] One Piece 10x14 214", "One Piece", 214, 10, 14)] [TestCase("[K-F] One Piece 214 10x14", "One Piece", 214, 10, 14)] - [TestCase("One Piece S10E14 214", "One Piece", 214, 10, 14)] - [TestCase("One Piece 10x14 214", "One Piece", 214, 10, 14)] - [TestCase("One Piece 214 10x14", "One Piece", 214, 10, 14)] - [TestCase("214 One Piece 10x14", "One Piece", 214, 10, 14)] +// [TestCase("One Piece S10E14 214", "One Piece", 214, 10, 14)] +// [TestCase("One Piece 10x14 214", "One Piece", 214, 10, 14)] +// [TestCase("One Piece 214 10x14", "One Piece", 214, 10, 14)] +// [TestCase("214 One Piece 10x14", "One Piece", 214, 10, 14)] [TestCase("Bleach - 031 - The Resolution to Kill [Lunar].avi", "Bleach", 31, 0, 0)] [TestCase("Bleach - 031 - The Resolution to Kill [Lunar]", "Bleach", 31, 0, 0)] [TestCase("[ACX]Hack Sign 01 Role Play [Kosaka] [9C57891E].mkv", "Hack Sign", 1, 0, 0)] diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index ea9a9185c..119711b1d 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -22,15 +22,16 @@ public static class Parser RegexOptions.IgnoreCase | RegexOptions.Compiled), //Anime - Absolute Episode Number + Title + Season+Episode - new Regex(@"^(?:(?\d{2,3})(?:_|-|\s|\.)+)+(?.+?)(?:\W|_)+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), + //Todo: This currently breaks series that start with numbers +// new Regex(@"^(?:(?<absoluteepisode>\d{2,3})(?:_|-|\s|\.)+)+(?<title>.+?)(?:\W|_)+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)", +// RegexOptions.IgnoreCase | RegexOptions.Compiled), //Anime - [SubGroup] Title Absolute Episode Number + Season+Episode - new Regex(@"^(?:\[(?<subgroup>.+?)\](?:_|-|\s|\.))?(?<title>.+?)(?:(?:\W|_)+(?<absoluteepisode>\d{2,3}))+(?:_|-|\s|\.)+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)", + new Regex(@"^(?:\[(?<subgroup>.+?)\](?:_|-|\s|\.))(?<title>.+?)(?:(?:\W|_)+(?<absoluteepisode>\d{2,3}))+(?:_|-|\s|\.)+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Anime - [SubGroup] Title Season+Episode + Absolute Episode Number - new Regex(@"^(?:\[(?<subgroup>.+?)\](?:_|-|\s|\.))?(?<title>.+?)(?:\W|_)+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)(?:\s|\.)(?:(?<absoluteepisode>\d{2,3})(?:_|-|\s|\.|$)+)+", + new Regex(@"^(?:\[(?<subgroup>.+?)\](?:_|-|\s|\.))(?<title>.+?)(?:\W|_)+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)(?:\s|\.)(?:(?<absoluteepisode>\d{2,3})(?:_|-|\s|\.|$)+)+", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Anime - [SubGroup] Title Absolute Episode Number