From 073342ef39cacebfbc280f167cdf87e276d70505 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 #2987 --- 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 | 3 ++ .../Config/DownloadClientConfigResource.cs | 6 ++-- 9 files changed, 59 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 bf3850f95..262143590 100644 --- a/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js +++ b/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js @@ -61,8 +61,12 @@ function DownloadClientOptions(props) { legend={translate('FailedDownloadHandling')} >
- - {translate('RedownloadFailed')} + + {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 994a33d93..db4e7f02b 100644 --- a/src/NzbDrone.Core/Configuration/ConfigService.cs +++ b/src/NzbDrone.Core/Configuration/ConfigService.cs @@ -144,6 +144,13 @@ namespace NzbDrone.Core.Configuration set { SetValue("AutoRedownloadFailed", value); } } + public bool AutoRedownloadFailedFromInteractiveSearch + { + get { return GetValueBoolean("AutoRedownloadFailedFromInteractiveSearch", true); } + + set { SetValue("AutoRedownloadFailedFromInteractiveSearch", value); } + } + public bool CreateEmptyAuthorFolders { get { return GetValueBoolean("CreateEmptyAuthorFolders", false); } diff --git a/src/NzbDrone.Core/Configuration/IConfigService.cs b/src/NzbDrone.Core/Configuration/IConfigService.cs index 89a107a45..1170f30de 100644 --- a/src/NzbDrone.Core/Configuration/IConfigService.cs +++ b/src/NzbDrone.Core/Configuration/IConfigService.cs @@ -19,6 +19,7 @@ namespace NzbDrone.Core.Configuration //Completed/Failed Download Handling (Download client) bool EnableCompletedDownloadHandling { get; set; } bool AutoRedownloadFailed { get; set; } + bool AutoRedownloadFailedFromInteractiveSearch { get; set; } //Media Management bool AutoUnmonitorPreviouslyDownloadedBooks { get; set; } diff --git a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs index a65cce3e0..ed79f86b4 100644 --- a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs +++ b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using NzbDrone.Common.Messaging; using NzbDrone.Core.Download.TrackedDownloads; +using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; namespace NzbDrone.Core.Download @@ -22,5 +23,6 @@ namespace NzbDrone.Core.Download public Dictionary Data { get; set; } public TrackedDownload TrackedDownload { 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 ecdcafd06..e7e71dff3 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 { @@ -117,6 +119,7 @@ namespace NzbDrone.Core.Download private void PublishDownloadFailedEvent(List historyItems, string message, TrackedDownload trackedDownload = null, bool skipRedownload = false) { var historyItem = historyItems.Last(); + Enum.TryParse(historyItem.Data.GetValueOrDefault(EntityHistory.RELEASE_SOURCE, ReleaseSourceType.Unknown.ToString()), out ReleaseSourceType releaseSource); var downloadFailedEvent = new DownloadFailedEvent { @@ -129,7 +132,8 @@ namespace NzbDrone.Core.Download Message = message, Data = historyItem.Data, TrackedDownload = trackedDownload, - 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 6ddcafe78..b1e384695 100644 --- a/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs @@ -5,6 +5,7 @@ using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Messaging; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Download { @@ -41,6 +42,12 @@ namespace NzbDrone.Core.Download return; } + if (message.ReleaseSource == ReleaseSourceType.InteractiveSearch && !_configService.AutoRedownloadFailedFromInteractiveSearch) + { + _logger.Debug("Auto redownloading failed albumbs from interactive search is disabled"); + return; + } + if (message.BookIds.Count == 1) { _logger.Debug("Failed download only contains one book, searching again"); diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index ac681f26e..3a208e3b3 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -61,6 +61,9 @@ "AuthorNameHelpText": "The name of the author/book to exclude (can be anything meaningful)", "Authors": "Authors", "AutoAdd": "Auto Add", + "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", "AutoUnmonitorPreviouslyDownloadedBooksHelpText": "Books deleted from disk are automatically unmonitored in Readarr", "Automatic": "Automatic", diff --git a/src/Readarr.Api.V1/Config/DownloadClientConfigResource.cs b/src/Readarr.Api.V1/Config/DownloadClientConfigResource.cs index 23239fd3e..a8dd274d3 100644 --- a/src/Readarr.Api.V1/Config/DownloadClientConfigResource.cs +++ b/src/Readarr.Api.V1/Config/DownloadClientConfigResource.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Configuration; +using NzbDrone.Core.Configuration; using Readarr.Http.REST; namespace Readarr.Api.V1.Config @@ -9,6 +9,7 @@ namespace Readarr.Api.V1.Config public bool EnableCompletedDownloadHandling { get; set; } public bool AutoRedownloadFailed { get; set; } + public bool AutoRedownloadFailedFromInteractiveSearch { get; set; } } public static class DownloadClientConfigResourceMapper @@ -20,7 +21,8 @@ namespace Readarr.Api.V1.Config DownloadClientWorkingFolders = model.DownloadClientWorkingFolders, EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling, - AutoRedownloadFailed = model.AutoRedownloadFailed + AutoRedownloadFailed = model.AutoRedownloadFailed, + AutoRedownloadFailedFromInteractiveSearch = model.AutoRedownloadFailedFromInteractiveSearch }; } }