From 4ff83f9efc8abb0890722c3f462fb884937c5e34 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 1 Aug 2024 08:15:36 +0300 Subject: [PATCH] Fixed: Persist Indexer Flags for automatic imports Revert "Fixed: Persist Indexer Flags when manual importing from queue" This reverts commit 217611d7165e2f24068697e4996f0dcfc54f786c. --- .../EpisodeImport/ImportDecisionMaker.cs | 14 ++++++++++++++ .../EpisodeImport/Manual/ManualImportService.cs | 13 ++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs index c3f07a0a5..d192c72f2 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs @@ -7,6 +7,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.CustomFormats; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; +using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Tv; @@ -29,6 +30,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport private readonly IAggregationService _aggregationService; private readonly IDiskProvider _diskProvider; private readonly IDetectSample _detectSample; + private readonly ITrackedDownloadService _trackedDownloadService; private readonly ICustomFormatCalculationService _formatCalculator; private readonly Logger _logger; @@ -37,6 +39,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport IAggregationService aggregationService, IDiskProvider diskProvider, IDetectSample detectSample, + ITrackedDownloadService trackedDownloadService, ICustomFormatCalculationService formatCalculator, Logger logger) { @@ -45,6 +48,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport _aggregationService = aggregationService; _diskProvider = diskProvider; _detectSample = detectSample; + _trackedDownloadService = trackedDownloadService; _formatCalculator = formatCalculator; _logger = logger; } @@ -145,6 +149,16 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport } else { + if (downloadClientItem?.DownloadId.IsNotNullOrWhiteSpace() == true) + { + var trackedDownload = _trackedDownloadService.Find(downloadClientItem.DownloadId); + + if (trackedDownload?.RemoteEpisode?.Release?.IndexerFlags != null) + { + localEpisode.IndexerFlags = trackedDownload.RemoteEpisode.Release.IndexerFlags; + } + } + localEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(localEpisode); localEpisode.CustomFormatScore = localEpisode.Series.QualityProfile?.Value.CalculateCustomFormatScore(localEpisode.CustomFormats) ?? 0; diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs index c82da9c78..c413172aa 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs @@ -215,7 +215,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual { DownloadClientItem downloadClientItem = null; Series series = null; - TrackedDownload trackedDownload = null; var directoryInfo = new DirectoryInfo(baseFolder); @@ -237,7 +236,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual if (downloadId.IsNotNullOrWhiteSpace()) { - trackedDownload = _trackedDownloadService.Find(downloadId); + var trackedDownload = _trackedDownloadService.Find(downloadId); downloadClientItem = trackedDownload.DownloadItem; if (series == null) @@ -273,11 +272,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual var seriesFiles = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder).ToList()); var decisions = _importDecisionMaker.GetImportDecisions(seriesFiles, series, downloadClientItem, folderInfo, SceneSource(series, baseFolder), filterExistingFiles); - foreach (var decision in decisions) - { - decision.LocalEpisode.IndexerFlags = trackedDownload?.RemoteEpisode?.Release?.IndexerFlags ?? 0; - } - return decisions.Select(decision => MapItem(decision, rootFolder, downloadId, directoryInfo.Name)).ToList(); } @@ -337,10 +331,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual if (importDecisions.Any()) { - var importDecision = importDecisions.First(); - importDecision.LocalEpisode.IndexerFlags = trackedDownload?.RemoteEpisode?.Release?.IndexerFlags ?? 0; - - return MapItem(importDecision, rootFolder, downloadId, null); + return MapItem(importDecisions.First(), rootFolder, downloadId, null); } } catch (Exception ex)