From 468ac1b7895119581e7b27f9f724ce1aac870bf4 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 10 Jan 2015 00:43:35 -0800 Subject: [PATCH] Release group parsing improvements Fixed: Clean title before parsing release group (remove -RP & -NZBGeek) Fixed: Parse subgroup from start of file name when inside square brackets --- .../ParserTests/HashedReleaseFixture.cs | 4 ++-- .../ParserTests/ReleaseGroupParserFixture.cs | 17 +++++++++++++++++ src/NzbDrone.Core/Parser/Parser.cs | 15 ++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs b/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs index 657392946..d2fd007a8 100644 --- a/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs @@ -41,10 +41,10 @@ namespace NzbDrone.Core.Test.ParserTests }, new object[] { - @"C:\Test\Weeds.S01E10.DVDRip.XviD-NZBgeek\AHFMZXGHEWD660.mkv".AsOsAgnostic(), + @"C:\Test\Weeds.S01E10.DVDRip.XviD-SONARR\AHFMZXGHEWD660.mkv".AsOsAgnostic(), "weeds", Quality.DVD, - "NZBgeek" + "SONARR" }, new object[] { diff --git a/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs index 481f40696..635a3b8c9 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs @@ -25,6 +25,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Simpsons 10x11 - Wild Barts Cant Be Broken [rl].avi", null)] [TestCase("[ www.Torrenting.com ] - Revenge.S03E14.720p.HDTV.X264-DIMENSION", "DIMENSION")] [TestCase("Seed S02E09 HDTV x264-2HD [eztv]-[rarbg.com]", "2HD")] + //[TestCase("", "")] public void should_parse_release_group(string title, string expected) { Parser.Parser.ParseReleaseGroup(title).Should().Be(expected); @@ -39,9 +40,25 @@ namespace NzbDrone.Core.Test.ParserTests } [TestCase("The.Longest.Mystery.S02E04.720p.WEB-DL.AAC2.0.H.264-EVL-RP", "EVL")] + [TestCase("Lost.S04E04.720p.BluRay.x264-xHD-NZBgeek", "xHD")] + [TestCase("Blue.Bloods.S05E11.720p.HDTV.X264-DIMENSION-NZBgeek", "DIMENSION")] + [TestCase("Lost.S04E04.720p.BluRay.x264-xHD-1", "xHD")] + [TestCase("Blue.Bloods.S05E11.720p.HDTV.X264-DIMENSION-1", "DIMENSION")] public void should_not_include_repost_in_release_group(string title, string expected) { Parser.Parser.ParseReleaseGroup(title).Should().Be(expected); } + + [TestCase("[FFF] Invaders of the Rokujouma!! - S01E11 - Someday, With Them", "FFF")] + [TestCase("[HorribleSubs] Invaders of the Rokujouma!! - S01E12 - Invasion Going Well!!", "HorribleSubs")] + [TestCase("[Anime-Koi] Barakamon - S01E06 - Guys From Tokyo", "Anime-Koi")] + [TestCase("[Anime-Koi] Barakamon - S01E07 - A High-Grade Fish", "Anime-Koi")] + [TestCase("[Anime-Koi] Kami-sama Hajimemashita 2 - 01 [h264-720p][28D54E2C]", "Anime-Koi")] + //[TestCase("Tokyo.Ghoul.02x01.013.HDTV-720p-Anime-Koi", "Anime-Koi")] + //[TestCase("", "")] + public void should_parse_anime_release_groups(string title, string expected) + { + Parser.Parser.ParseReleaseGroup(title).Should().Be(expected); + } } } diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index ba357230c..7f13c0321 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -165,9 +165,15 @@ namespace NzbDrone.Core.Parser private static readonly Regex SixDigitAirDateRegex = new Regex(@"(?<=[_.-])(?(?[1-9]\d{1})(?[0-1][0-9])(?[0-3][0-9]))(?=[_.-])", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex CleanReleaseGroupRegex = new Regex(@"^(\[\s.+?\s\])|-(RP|1|NZBGeek)$", + RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex ReleaseGroupRegex = new Regex(@"-(?[a-z0-9]+)\b(?(?\bita\b|italian)|(?german\b|videomann)|(?flemish)|(?greek)|(?(?:\W|_)(?:FR|VOSTFR)(?:\W|_))|(?\brus\b)|(?nl\W?subs?)", RegexOptions.IgnoreCase | RegexOptions.Compiled); @@ -356,7 +362,14 @@ namespace NzbDrone.Core.Parser { title = title.Trim(); title = RemoveFileExtension(title); - title = title.TrimEnd("-RP"); + title = CleanReleaseGroupRegex.Replace(title, ""); + + var animeMatch = AnimeReleaseGroupRegex.Match(title); + + if (animeMatch.Success) + { + return animeMatch.Groups["subgroup"].Value; + } var matches = ReleaseGroupRegex.Matches(title);