From 35eeef3af62688dc388d24fb784e415e74d7387f Mon Sep 17 00:00:00 2001
From: Qstick <qstick@gmail.com>
Date: Tue, 17 Oct 2017 21:07:10 -0400
Subject: [PATCH] Fix Search Fail When Cannot Parse a Release

---
 .../DecisionEngine/DownloadDecisionMaker.cs   | 45 ++++++++++---------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs
index c52302b28..c7aea4b34 100644
--- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs
+++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs
@@ -62,33 +62,36 @@ namespace NzbDrone.Core.DecisionEngine
                 {
                     var parsedAlbumInfo = Parser.Parser.ParseAlbumTitle(report.Title);
 
-                    if (!report.Artist.IsNullOrWhiteSpace())
+                    if (parsedAlbumInfo != null)
                     {
-                        parsedAlbumInfo.ArtistName = report.Artist;
-                    }
-
-                    if (!report.Album.IsNullOrWhiteSpace())
-                    {
-                        parsedAlbumInfo.AlbumTitle = report.Album;
-                    }
-
-                    if (parsedAlbumInfo != null && !parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace())
-                    {
-                        var remoteAlbum = _parsingService.Map(parsedAlbumInfo, searchCriteria);
-                        remoteAlbum.Release = report;
-
-                        if (remoteAlbum.Artist == null)
+                        if (!report.Artist.IsNullOrWhiteSpace())
                         {
-                            decision = new DownloadDecision(remoteAlbum, new Rejection("Unknown Artist"));
+                            parsedAlbumInfo.ArtistName = report.Artist;
                         }
-                        else if (remoteAlbum.Albums.Empty())
+
+                        if (!report.Album.IsNullOrWhiteSpace())
                         {
-                            decision = new DownloadDecision(remoteAlbum, new Rejection("Unable to parse albums from release name"));
+                            parsedAlbumInfo.AlbumTitle = report.Album;
                         }
-                        else
+
+                        if (!parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace())
                         {
-                            remoteAlbum.DownloadAllowed = remoteAlbum.Albums.Any();
-                            decision = GetDecisionForReport(remoteAlbum, searchCriteria);
+                            var remoteAlbum = _parsingService.Map(parsedAlbumInfo, searchCriteria);
+                            remoteAlbum.Release = report;
+
+                            if (remoteAlbum.Artist == null)
+                            {
+                                decision = new DownloadDecision(remoteAlbum, new Rejection("Unknown Artist"));
+                            }
+                            else if (remoteAlbum.Albums.Empty())
+                            {
+                                decision = new DownloadDecision(remoteAlbum, new Rejection("Unable to parse albums from release name"));
+                            }
+                            else
+                            {
+                                remoteAlbum.DownloadAllowed = remoteAlbum.Albums.Any();
+                                decision = GetDecisionForReport(remoteAlbum, searchCriteria);
+                            }
                         }
                     }
                 }