Fixed: Better release parsing (#541)

pull/554/head
ta264 6 years ago committed by Qstick
parent e260a29b57
commit d62b4e49f9

@ -182,6 +182,8 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Black Sabbath Black Sabbath FLAC")]
[TestCase("BlaCk SabBaTh Black SabBatH FLAC")]
[TestCase("Black Sabbath FLAC Black Sabbath")]
[TestCase("Black.Sabbath-FLAC-Black.Sabbath")]
[TestCase("Black_Sabbath-FLAC-Black_Sabbath")]
public void should_parse_artist_name_and_album_title_by_search_criteria(string releaseTitle)
{
GivenSearchCriteria("Black Sabbath", "Black Sabbath");

@ -89,6 +89,21 @@ namespace NzbDrone.Core.DecisionEngine
if (!parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace())
{
var remoteAlbum = _parsingService.Map(parsedAlbumInfo, searchCriteria);
// try parsing again using the search criteria, in case it parsed but parsed incorrectly
if ((remoteAlbum.Artist == null || remoteAlbum.Albums.Empty()) && searchCriteria != null)
{
_logger.Debug("Artist/Album null for {0}, reparsing with search criteria", report.Title);
var parsedAlbumInfoWithCriteria = Parser.Parser.ParseAlbumTitleWithSearchCriteria(report.Title,
searchCriteria.Artist,
searchCriteria.Albums);
if (parsedAlbumInfoWithCriteria != null && parsedAlbumInfoWithCriteria.ArtistName.IsNotNullOrWhiteSpace())
{
remoteAlbum = _parsingService.Map(parsedAlbumInfoWithCriteria, searchCriteria);
}
}
remoteAlbum.Release = report;
if (remoteAlbum.Artist == null)

@ -342,8 +342,8 @@ namespace NzbDrone.Core.Parser
{
if (!ValidateBeforeParsing(title)) return null;
Logger.Debug("Parsing string '{0}'", title);
Logger.Debug("Parsing string '{0}' using search criteria artist: '{1}' album: '{2}'",
title, artist.Name, string.Join(", ", album.Select(a => a.Title)));
if (ReversedTitleRegex.IsMatch(title))
{
@ -363,8 +363,8 @@ namespace NzbDrone.Core.Parser
simpleTitle = CleanTorrentSuffixRegex.Replace(simpleTitle, string.Empty);
var escapedArtist = Regex.Escape(artist.Name);
var escapedAlbums = Regex.Escape(string.Join("|", album.Select(s => s.Title).ToList()));
var escapedArtist = Regex.Escape(artist.Name).Replace(@"\ ", @"[\W_]");
var escapedAlbums = Regex.Escape(string.Join("|", album.Select(s => s.Title).ToList())).Replace(@"\ ", @"[\W_]");;
var releaseRegex = new Regex(@"^(\W*|\b)(?<artist>" + escapedArtist + @")(\W*|\b).*(\W*|\b)(?<album>" + escapedAlbums + @")(\W*|\b)", RegexOptions.IgnoreCase);

Loading…
Cancel
Save