mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-31 12:10:19 -07:00
Fixed: Better release parsing (#541)
This commit is contained in:
parent
e260a29b57
commit
d62b4e49f9
3 changed files with 21 additions and 4 deletions
|
@ -182,6 +182,8 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
[TestCase("Black Sabbath Black Sabbath FLAC")]
|
[TestCase("Black Sabbath Black Sabbath FLAC")]
|
||||||
[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")]
|
||||||
|
[TestCase("Black_Sabbath-FLAC-Black_Sabbath")]
|
||||||
public void should_parse_artist_name_and_album_title_by_search_criteria(string releaseTitle)
|
public void should_parse_artist_name_and_album_title_by_search_criteria(string releaseTitle)
|
||||||
{
|
{
|
||||||
GivenSearchCriteria("Black Sabbath", "Black Sabbath");
|
GivenSearchCriteria("Black Sabbath", "Black Sabbath");
|
||||||
|
|
|
@ -89,6 +89,21 @@ namespace NzbDrone.Core.DecisionEngine
|
||||||
if (!parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace())
|
if (!parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var remoteAlbum = _parsingService.Map(parsedAlbumInfo, searchCriteria);
|
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;
|
remoteAlbum.Release = report;
|
||||||
|
|
||||||
if (remoteAlbum.Artist == null)
|
if (remoteAlbum.Artist == null)
|
||||||
|
|
|
@ -342,8 +342,8 @@ namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
if (!ValidateBeforeParsing(title)) return null;
|
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))
|
if (ReversedTitleRegex.IsMatch(title))
|
||||||
{
|
{
|
||||||
|
@ -363,8 +363,8 @@ namespace NzbDrone.Core.Parser
|
||||||
|
|
||||||
simpleTitle = CleanTorrentSuffixRegex.Replace(simpleTitle, string.Empty);
|
simpleTitle = CleanTorrentSuffixRegex.Replace(simpleTitle, string.Empty);
|
||||||
|
|
||||||
var escapedArtist = Regex.Escape(artist.Name);
|
var escapedArtist = Regex.Escape(artist.Name).Replace(@"\ ", @"[\W_]");
|
||||||
var escapedAlbums = Regex.Escape(string.Join("|", album.Select(s => s.Title).ToList()));
|
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);
|
var releaseRegex = new Regex(@"^(\W*|\b)(?<artist>" + escapedArtist + @")(\W*|\b).*(\W*|\b)(?<album>" + escapedAlbums + @")(\W*|\b)", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue