From 531e9486872058b157a066451697ef24593cf464 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 10 Aug 2023 00:34:11 +0300 Subject: [PATCH] Align DownloadService with upstream --- src/NzbDrone.Core/Download/DownloadService.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/Download/DownloadService.cs b/src/NzbDrone.Core/Download/DownloadService.cs index 5eacaef10..bbc622ee7 100644 --- a/src/NzbDrone.Core/Download/DownloadService.cs +++ b/src/NzbDrone.Core/Download/DownloadService.cs @@ -51,13 +51,21 @@ namespace NzbDrone.Core.Download public void DownloadReport(RemoteMovie remoteMovie) { - Ensure.That(remoteMovie.Movie, () => remoteMovie.Movie).IsNotNull(); - - var downloadTitle = remoteMovie.Release.Title; var filterBlockedClients = remoteMovie.Release.PendingReleaseReason == PendingReleaseReason.DownloadClientUnavailable; + var tags = remoteMovie.Movie?.Tags; + var downloadClient = _downloadClientProvider.GetDownloadClient(remoteMovie.Release.DownloadProtocol, remoteMovie.Release.IndexerId, filterBlockedClients, tags); + DownloadReport(remoteMovie, downloadClient); + } + + public void DownloadReport(RemoteMovie remoteMovie, IDownloadClient downloadClient) + { + Ensure.That(remoteMovie.Movie, () => remoteMovie.Movie).IsNotNull(); + + var downloadTitle = remoteMovie.Release.Title; + if (downloadClient == null) { throw new DownloadClientUnavailableException($"{remoteMovie.Release.DownloadProtocol} Download client isn't configured yet"); @@ -99,8 +107,7 @@ namespace NzbDrone.Core.Download } catch (ReleaseDownloadException ex) { - var http429 = ex.InnerException as TooManyRequestsException; - if (http429 != null) + if (ex.InnerException is TooManyRequestsException http429) { _indexerStatusService.RecordFailure(remoteMovie.Release.IndexerId, http429.RetryAfter); }