From 9216fe28d016dbab64b3106994ee3e01457e0d88 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 7 Oct 2019 09:38:11 -0700 Subject: [PATCH] Fixed: Include releases that failed to parse in search results Signed-off-by: Robin Dadswell --- .../DownloadDecisionMakerFixture.cs | 23 ++++++++++++++++--- .../DecisionEngine/DownloadDecisionMaker.cs | 22 ++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs index 85e8f66f2..539feec6e 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs @@ -152,7 +152,7 @@ public void should_not_attempt_to_map_album_if_not_parsable() GivenSpecifications(_pass1, _pass2, _pass3); _reports[0].Title = "Not parsable"; - var results = Subject.GetRssDecision(_reports).ToList(); + Subject.GetRssDecision(_reports).ToList(); Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Never()); @@ -160,11 +160,10 @@ public void should_not_attempt_to_map_album_if_not_parsable() _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - results.Should().BeEmpty(); } [Test] - public void should_not_attempt_to_map_album_artist_title_is_blank() + public void should_not_attempt_to_map_album_if_artist_title_is_blank() { GivenSpecifications(_pass1, _pass2, _pass3); _reports[0].Title = "2013 - Night Visions"; @@ -180,6 +179,24 @@ public void should_not_attempt_to_map_album_artist_title_is_blank() results.Should().BeEmpty(); } + [Test] + public void should_return_rejected_result_for_unparsable_search() + { + GivenSpecifications(_pass1, _pass2, _pass3); + _reports[0].Title = "1937 - Snow White and the Seven Dwarves"; + + var artist = new Artist { Name = "Some Artist" }; + var albums = new List { new Album { Title = "Some Album" } }; + + Subject.GetSearchDecision(_reports, new AlbumSearchCriteria { Artist = artist, Albums = albums }).ToList(); + + Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Never()); + + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + } + [Test] public void should_not_attempt_to_make_decision_if_artist_is_unknown() { diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 8c3c8dd99..f1a7da30f 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -153,6 +153,28 @@ private IEnumerable GetBookDecisions(List reports decision = new DownloadDecision(remoteBook, new Rejection("Unable to parse release")); } } + + if (searchCriteria != null) + { + if (parsedAlbumInfo == null) + { + parsedAlbumInfo = new ParsedAlbumInfo + { + Quality = QualityParser.ParseQuality(report.Title, null, 0) + }; + } + + if (parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace()) + { + var remoteAlbum = new RemoteAlbum + { + Release = report, + ParsedAlbumInfo = parsedAlbumInfo + }; + + decision = new DownloadDecision(remoteAlbum, new Rejection("Unable to parse release")); + } + } } catch (Exception e) {