From 734b1f6101cb5f9d28d4d9005d8c98ef58e32fdf Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Mon, 9 Apr 2018 20:37:56 -0500 Subject: [PATCH] Added cases to strip feat. from track titles. (#288) * Added cases to strip feat. from track titles. --- .../ParserTests/ParserFixture.cs | 4 ++++ src/NzbDrone.Core/Parser/Parser.cs | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 65ece57fe..e60b3cefd 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -60,6 +60,10 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Songs of Experience (Deluxe Edition)", "Songs of Experience")] [TestCase("Mr. Bad Guy [Special Edition]", "Mr. Bad Guy")] [TestCase("Smooth Criminal (single)", "Smooth Criminal")] + [TestCase("Wie Maak Die Jol Vol (Ft. Isaac Mutant, Knoffel, Jaak Paarl & Scallywag)", "Wie Maak Die Jol Vol")] + [TestCase("Alles Schon Gesehen (Feat. Deichkind)", "Alles Schon Gesehen")] + [TestCase("Science Fiction/Double Feature", "Science Fiction/Double Feature")] + [TestCase("Dancing Feathers", "Dancing Feathers")] public void should_remove_common_tags_from_track_title(string title, string correct) { var result = Parser.Parser.CleanTrackTitle(title); diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index cc5d149cb..c2d573a56 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -200,7 +200,10 @@ namespace NzbDrone.Core.Parser private static readonly string[] Numbers = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; - private static readonly Regex CommonTagRegex = new Regex(@"(\[|\(){1}(version|limited|deluxe|single|clean|album|special|bonus)+\s*.*(\]|\)){1}", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex[] CommonTagRegex = new Regex[] { + new Regex(@"(\[|\()*\b((featuring|feat.|feat|ft|ft.)\s{1}){1}\s*.*(\]|\))*", RegexOptions.IgnoreCase | RegexOptions.Compiled), + new Regex(@"(\[|\(){1}(version|limited|deluxe|single|clean|album|special|bonus)+\s*.*(\]|\)){1}", RegexOptions.IgnoreCase | RegexOptions.Compiled), + }; public static ParsedTrackInfo ParseMusicPath(string path) { @@ -588,12 +591,18 @@ namespace NzbDrone.Core.Parser public static string CleanAlbumTitle(string album) { - return CommonTagRegex.Replace(album, string.Empty).Trim(); + return CommonTagRegex[1].Replace(album, string.Empty).Trim(); } public static string CleanTrackTitle(string title) { - return CommonTagRegex.Replace(title, string.Empty).Trim(); + var intermediateTitle = title; + foreach (var regex in CommonTagRegex) + { + intermediateTitle = regex.Replace(intermediateTitle, string.Empty).Trim(); + } + + return intermediateTitle; } private static ParsedTrackInfo ParseAudioTags(string path)