Added cases to strip feat. from track titles. (#288)

* Added cases to strip feat. from track titles.
This commit is contained in:
Joseph Milazzo 2018-04-09 20:37:56 -05:00 committed by GitHub
parent 453bbeee20
commit 734b1f6101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -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);

View File

@ -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)