From e73015010e7d73fa01c44b8e49b75bbf5bd99061 Mon Sep 17 00:00:00 2001 From: Stevie Robinson Date: Thu, 1 Feb 2024 04:38:51 +0100 Subject: [PATCH] New: Send 'On Manual Interaction Required' notifications in more cases (cherry picked from commit c5a724f14eec20acf565ac3a036944191b30cab0) Closes #9722 --- .../Download/CompletedDownloadService.cs | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/NzbDrone.Core/Download/CompletedDownloadService.cs b/src/NzbDrone.Core/Download/CompletedDownloadService.cs index c0ee0df27..3be210728 100644 --- a/src/NzbDrone.Core/Download/CompletedDownloadService.cs +++ b/src/NzbDrone.Core/Download/CompletedDownloadService.cs @@ -94,7 +94,9 @@ public void Check(TrackedDownload trackedDownload) if (movie == null) { - trackedDownload.Warn("Movie title mismatch, Manual Import required."); + trackedDownload.Warn("Movie title mismatch, automatic import is not possible. Manual Import required."); + SendManualInteractionRequiredNotification(trackedDownload); + return; } @@ -105,16 +107,7 @@ public void Check(TrackedDownload trackedDownload) if (movieMatchType == MovieMatchType.Id && releaseSource != ReleaseSourceType.InteractiveSearch) { trackedDownload.Warn("Found matching movie via grab history, but release was matched to movie by ID. Manual Import required."); - - if (!trackedDownload.HasNotifiedManualInteractionRequired) - { - trackedDownload.HasNotifiedManualInteractionRequired = true; - - var releaseInfo = new GrabbedReleaseInfo(grabbedHistories); - var manualInteractionEvent = new ManualInteractionRequiredEvent(trackedDownload, releaseInfo); - - _eventAggregator.PublishEvent(manualInteractionEvent); - } + SendManualInteractionRequiredNotification(trackedDownload); return; } @@ -132,18 +125,21 @@ public void Import(TrackedDownload trackedDownload) return; } - trackedDownload.State = TrackedDownloadState.Importing; - - var outputPath = trackedDownload.ImportItem.OutputPath.FullPath; - if (trackedDownload.RemoteMovie?.Movie == null) { - trackedDownload.State = TrackedDownloadState.ImportPending; - trackedDownload.Warn("Unknown Movie", outputPath); + trackedDownload.Warn("Unable to parse download, automatic import is not possible."); + SendManualInteractionRequiredNotification(trackedDownload); + return; } - var importResults = _downloadedMovieImportService.ProcessPath(outputPath, ImportMode.Auto, trackedDownload.RemoteMovie.Movie, trackedDownload.ImportItem); + trackedDownload.State = TrackedDownloadState.Importing; + + var outputPath = trackedDownload.ImportItem.OutputPath.FullPath; + var importResults = _downloadedMovieImportService.ProcessPath(outputPath, + ImportMode.Auto, + trackedDownload.RemoteMovie.Movie, + trackedDownload.ImportItem); if (VerifyImport(trackedDownload, importResults)) { @@ -190,6 +186,7 @@ public void Import(TrackedDownload trackedDownload) if (statusMessages.Any()) { trackedDownload.Warn(statusMessages.ToArray()); + SendManualInteractionRequiredNotification(trackedDownload); } } @@ -248,6 +245,21 @@ public bool VerifyImport(TrackedDownload trackedDownload, List imp return false; } + private void SendManualInteractionRequiredNotification(TrackedDownload trackedDownload) + { + if (!trackedDownload.HasNotifiedManualInteractionRequired) + { + var grabbedHistories = _historyService.FindByDownloadId(trackedDownload.DownloadItem.DownloadId).Where(h => h.EventType == MovieHistoryEventType.Grabbed).ToList(); + + trackedDownload.HasNotifiedManualInteractionRequired = true; + + var releaseInfo = grabbedHistories.Count > 0 ? new GrabbedReleaseInfo(grabbedHistories) : null; + var manualInteractionEvent = new ManualInteractionRequiredEvent(trackedDownload, releaseInfo); + + _eventAggregator.PublishEvent(manualInteractionEvent); + } + } + private void SetImportItem(TrackedDownload trackedDownload) { trackedDownload.ImportItem = _provideImportItemService.ProvideImportItem(trackedDownload.DownloadItem, trackedDownload.ImportItem);