From e0c8a8f0d636ee2db7801d5d01c4db5b43739a8c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 6 Oct 2023 13:10:46 -0700 Subject: [PATCH] New: Download client option for redownloading failed releases from Interactive Search (cherry picked from commit 87e0a7983a437a4d166aa8b9c9eaf78ea5431969) Closes #9260 --- frontend/src/Components/Form/FormLabel.css | 4 ++- .../Options/DownloadClientOptions.js | 29 +++++++++++++++++-- .../Configuration/ConfigService.cs | 7 +++++ .../Configuration/IConfigService.cs | 1 + .../Download/DownloadFailedEvent.cs | 2 ++ .../Download/FailedDownloadService.cs | 6 +++- .../RedownloadFailedDownloadService.cs | 7 +++++ src/NzbDrone.Core/Localization/Core/en.json | 4 ++- .../Config/DownloadClientConfigResource.cs | 4 ++- 9 files changed, 58 insertions(+), 6 deletions(-) diff --git a/frontend/src/Components/Form/FormLabel.css b/frontend/src/Components/Form/FormLabel.css index 074b6091d..54a4678e8 100644 --- a/frontend/src/Components/Form/FormLabel.css +++ b/frontend/src/Components/Form/FormLabel.css @@ -2,8 +2,10 @@ display: flex; justify-content: flex-end; margin-right: $formLabelRightMarginWidth; + padding-top: 8px; + min-height: 35px; + text-align: end; font-weight: bold; - line-height: 35px; } .hasError { diff --git a/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js b/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js index 953f90700..389ad1e23 100644 --- a/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js +++ b/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js @@ -80,8 +80,12 @@ function DownloadClientOptions(props) { legend={translate('FailedDownloadHandling')} >
- - {translate('Redownload')} + + {translate('AutoRedownloadFailed')} + + { + settings.autoRedownloadFailed.value ? + + {translate('AutoRedownloadFailedFromInteractiveSearch')} + + + : + null + } + {translate('RemoveDownloadsAlert')} diff --git a/src/NzbDrone.Core/Configuration/ConfigService.cs b/src/NzbDrone.Core/Configuration/ConfigService.cs index 524fd5a41..8b9f3be9d 100644 --- a/src/NzbDrone.Core/Configuration/ConfigService.cs +++ b/src/NzbDrone.Core/Configuration/ConfigService.cs @@ -190,6 +190,13 @@ public bool AutoRedownloadFailed set { SetValue("AutoRedownloadFailed", value); } } + public bool AutoRedownloadFailedFromInteractiveSearch + { + get { return GetValueBoolean("AutoRedownloadFailedFromInteractiveSearch", true); } + + set { SetValue("AutoRedownloadFailedFromInteractiveSearch", value); } + } + public bool CreateEmptyMovieFolders { get { return GetValueBoolean("CreateEmptyMovieFolders", false); } diff --git a/src/NzbDrone.Core/Configuration/IConfigService.cs b/src/NzbDrone.Core/Configuration/IConfigService.cs index 41d4245d9..c54215ecf 100644 --- a/src/NzbDrone.Core/Configuration/IConfigService.cs +++ b/src/NzbDrone.Core/Configuration/IConfigService.cs @@ -22,6 +22,7 @@ public interface IConfigService bool EnableCompletedDownloadHandling { get; set; } bool AutoRedownloadFailed { get; set; } + bool AutoRedownloadFailedFromInteractiveSearch { get; set; } // Media Management bool AutoUnmonitorPreviouslyDownloadedMovies { get; set; } diff --git a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs index 019adb08c..d796b17bd 100644 --- a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs +++ b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs @@ -2,6 +2,7 @@ using NzbDrone.Common.Messaging; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Languages; +using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; namespace NzbDrone.Core.Download @@ -23,5 +24,6 @@ public DownloadFailedEvent() public TrackedDownload TrackedDownload { get; set; } public List Languages { get; set; } public bool SkipRedownload { get; set; } + public ReleaseSourceType ReleaseSource { get; set; } } } diff --git a/src/NzbDrone.Core/Download/FailedDownloadService.cs b/src/NzbDrone.Core/Download/FailedDownloadService.cs index 9b2ac04b2..cdd8e8dbe 100644 --- a/src/NzbDrone.Core/Download/FailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/FailedDownloadService.cs @@ -1,9 +1,11 @@ +using System; using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Download { @@ -128,6 +130,7 @@ public void ProcessFailed(TrackedDownload trackedDownload) private void PublishDownloadFailedEvent(List historyItems, string message, TrackedDownload trackedDownload = null, bool skipRedownload = false) { var historyItem = historyItems.First(); + Enum.TryParse(historyItem.Data.GetValueOrDefault(MovieHistory.RELEASE_SOURCE, ReleaseSourceType.Unknown.ToString()), out ReleaseSourceType releaseSource); var downloadFailedEvent = new DownloadFailedEvent { @@ -140,7 +143,8 @@ private void PublishDownloadFailedEvent(List historyItems, string Data = historyItem.Data, TrackedDownload = trackedDownload, Languages = historyItem.Languages, - SkipRedownload = skipRedownload + SkipRedownload = skipRedownload, + ReleaseSource = releaseSource }; _eventAggregator.PublishEvent(downloadFailedEvent); diff --git a/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs b/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs index 18b7cb2aa..a2568a6a7 100644 --- a/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs @@ -5,6 +5,7 @@ using NzbDrone.Core.Messaging; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Download { @@ -38,6 +39,12 @@ public void Handle(DownloadFailedEvent message) return; } + if (message.ReleaseSource == ReleaseSourceType.InteractiveSearch && !_configService.AutoRedownloadFailedFromInteractiveSearch) + { + _logger.Debug("Auto redownloading failed movies from interactive search is disabled"); + return; + } + if (message.MovieId != 0) { _logger.Debug("Failed download contains a movie, searching again."); diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index f2e614eef..396d4e8f7 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -89,6 +89,9 @@ "AuthenticationRequiredUsernameHelpTextWarning": "Enter a new username", "AuthenticationRequiredWarning": "To prevent remote access without authentication, {appName} now requires authentication to be enabled. You can optionally disable authentication from local addresses.", "Auto": "Auto", + "AutoRedownloadFailed": "Redownload Failed", + "AutoRedownloadFailedFromInteractiveSearch": "Redownload Failed from Interactive Search", + "AutoRedownloadFailedFromInteractiveSearchHelpText": "Automatically search for and attempt to download a different release when failed release was grabbed from interactive search", "AutoRedownloadFailedHelpText": "Automatically search for and attempt to download a different release", "AutoTagging": "Auto Tagging", "AutoTaggingNegateHelpText": "If checked, the auto tagging rule will not apply if this {0} condition matches.", @@ -908,7 +911,6 @@ "RecyclingBin": "Recycling Bin", "RecyclingBinCleanup": "Recycling Bin Cleanup", "Reddit": "Reddit", - "Redownload": "Redownload", "Refresh": "Refresh", "RefreshAndScan": "Refresh & Scan", "RefreshCollections": "Refresh Collections", diff --git a/src/Radarr.Api.V3/Config/DownloadClientConfigResource.cs b/src/Radarr.Api.V3/Config/DownloadClientConfigResource.cs index e572b8b33..53a44f4f5 100644 --- a/src/Radarr.Api.V3/Config/DownloadClientConfigResource.cs +++ b/src/Radarr.Api.V3/Config/DownloadClientConfigResource.cs @@ -11,6 +11,7 @@ public class DownloadClientConfigResource : RestResource public int CheckForFinishedDownloadInterval { get; set; } public bool AutoRedownloadFailed { get; set; } + public bool AutoRedownloadFailedFromInteractiveSearch { get; set; } } public static class DownloadClientConfigResourceMapper @@ -24,7 +25,8 @@ public static DownloadClientConfigResource ToResource(IConfigService model) EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling, CheckForFinishedDownloadInterval = model.CheckForFinishedDownloadInterval, - AutoRedownloadFailed = model.AutoRedownloadFailed + AutoRedownloadFailed = model.AutoRedownloadFailed, + AutoRedownloadFailedFromInteractiveSearch = model.AutoRedownloadFailedFromInteractiveSearch }; } }