From cce7ffa6acb4f09a41ad3fdf513675c13aa68270 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 12 Dec 2022 22:44:08 -0800 Subject: [PATCH] Fixed: Queue not showing items with conflicting titles (cherry picked from commit 789a8f53013a247cd195f864484089c27b5f3858) (cherry picked from commit 96b31e3c94f178cacabeb2bedd57fd4316e52380) --- .../DownloadMonitoringService.cs | 10 +++++---- .../TrackedDownloadService.cs | 17 ++++++++++----- .../Music/MultipleArtistsFoundException.cs | 21 +++++-------------- .../Music/Repositories/ArtistRepository.cs | 2 +- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs index 4ab3b23da..64fa7bfeb 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs @@ -111,24 +111,26 @@ private List ProcessClientDownloads(IDownloadClient downloadCli private TrackedDownload ProcessClientItem(IDownloadClient downloadClient, DownloadClientItem downloadItem) { + TrackedDownload trackedDownload = null; + try { - var trackedDownload = _trackedDownloadService.TrackDownload((DownloadClientDefinition)downloadClient.Definition, downloadItem); + trackedDownload = + _trackedDownloadService.TrackDownload((DownloadClientDefinition)downloadClient.Definition, + downloadItem); if (trackedDownload is { State: TrackedDownloadState.Downloading or TrackedDownloadState.ImportBlocked }) { _failedDownloadService.Check(trackedDownload); _completedDownloadService.Check(trackedDownload); } - - return trackedDownload; } catch (Exception e) { _logger.Error(e, "Couldn't process tracked download {0}", downloadItem.Title); } - return null; + return trackedDownload; } private bool DownloadIsTrackable(TrackedDownload trackedDownload) diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs index 085373b56..4d5ada4b5 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -169,8 +169,8 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do { trackedDownload.RemoteAlbum = _parsingService.Map(parsedAlbumInfo, firstHistoryItem.ArtistId, - historyItems.Where(v => v.EventType == EntityHistoryEventType.Grabbed).Select(h => h.AlbumId) - .Distinct()); + historyItems.Where(v => v.EventType == EntityHistoryEventType.Grabbed) + .Select(h => h.AlbumId).Distinct()); } else { @@ -183,8 +183,8 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do { trackedDownload.RemoteAlbum = _parsingService.Map(parsedAlbumInfo, firstHistoryItem.ArtistId, - historyItems.Where(v => v.EventType == EntityHistoryEventType.Grabbed).Select(h => h.AlbumId) - .Distinct()); + historyItems.Where(v => v.EventType == EntityHistoryEventType.Grabbed) + .Select(h => h.AlbumId).Distinct()); } } } @@ -211,10 +211,17 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do _logger.Trace("No Album found for download '{0}'", trackedDownload.DownloadItem.Title); } } + catch (MultipleArtistsFoundException e) + { + _logger.Debug(e, "Found multiple artists for " + downloadItem.Title); + + trackedDownload.Warn("Unable to import automatically, found multiple artists: {0}", string.Join(", ", e.Artists)); + } catch (Exception e) { _logger.Debug(e, "Failed to find album for " + downloadItem.Title); - return null; + + trackedDownload.Warn("Unable to parse albums from title"); } LogItemChange(trackedDownload, existingItem?.DownloadItem, trackedDownload.DownloadItem); diff --git a/src/NzbDrone.Core/Music/MultipleArtistsFoundException.cs b/src/NzbDrone.Core/Music/MultipleArtistsFoundException.cs index fdc6a348f..1aee179f0 100644 --- a/src/NzbDrone.Core/Music/MultipleArtistsFoundException.cs +++ b/src/NzbDrone.Core/Music/MultipleArtistsFoundException.cs @@ -1,27 +1,16 @@ +using System.Collections.Generic; using NzbDrone.Common.Exceptions; namespace NzbDrone.Core.Music { public class MultipleArtistsFoundException : NzbDroneException { - public MultipleArtistsFoundException(string message, params object[] args) + public List Artists { get; } + + public MultipleArtistsFoundException(List artists, string message, params object[] args) : base(message, args) { - } - - public MultipleArtistsFoundException(string message) - : base(message) - { - } - - public MultipleArtistsFoundException(string message, System.Exception innerException) - : base(message, innerException) - { - } - - protected MultipleArtistsFoundException(string message, System.Exception innerException, params object[] args) - : base(message, innerException, args) - { + Artists = artists; } } } diff --git a/src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs b/src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs index f11194c54..5bf3d908d 100644 --- a/src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs +++ b/src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs @@ -106,7 +106,7 @@ private static Artist ReturnSingleArtistOrThrow(List artists) return artists[0]; } - throw new MultipleArtistsFoundException("Expected one artist, but found {0}. Matching artists: {1}", artists.Count, string.Join(",", artists.Select(s => s.Name))); + throw new MultipleArtistsFoundException(artists, "Expected one artist, but found {0}. Matching artists: {1}", artists.Count, string.Join(", ", artists)); } } }