1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2025-01-03 05:35:29 +00:00

Fixed: Persist Indexer Flags for automatic imports

Revert "Fixed: Persist Indexer Flags when manual importing from queue"

This reverts commit 217611d716.
This commit is contained in:
Bogdan 2024-08-01 08:15:36 +03:00 committed by GitHub
parent 217611d716
commit 4ff83f9efc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 11 deletions

View file

@ -7,6 +7,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Core.CustomFormats; using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation; using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
@ -29,6 +30,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
private readonly IAggregationService _aggregationService; private readonly IAggregationService _aggregationService;
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IDetectSample _detectSample; private readonly IDetectSample _detectSample;
private readonly ITrackedDownloadService _trackedDownloadService;
private readonly ICustomFormatCalculationService _formatCalculator; private readonly ICustomFormatCalculationService _formatCalculator;
private readonly Logger _logger; private readonly Logger _logger;
@ -37,6 +39,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
IAggregationService aggregationService, IAggregationService aggregationService,
IDiskProvider diskProvider, IDiskProvider diskProvider,
IDetectSample detectSample, IDetectSample detectSample,
ITrackedDownloadService trackedDownloadService,
ICustomFormatCalculationService formatCalculator, ICustomFormatCalculationService formatCalculator,
Logger logger) Logger logger)
{ {
@ -45,6 +48,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
_aggregationService = aggregationService; _aggregationService = aggregationService;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_detectSample = detectSample; _detectSample = detectSample;
_trackedDownloadService = trackedDownloadService;
_formatCalculator = formatCalculator; _formatCalculator = formatCalculator;
_logger = logger; _logger = logger;
} }
@ -145,6 +149,16 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
} }
else 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.CustomFormats = _formatCalculator.ParseCustomFormat(localEpisode);
localEpisode.CustomFormatScore = localEpisode.Series.QualityProfile?.Value.CalculateCustomFormatScore(localEpisode.CustomFormats) ?? 0; localEpisode.CustomFormatScore = localEpisode.Series.QualityProfile?.Value.CalculateCustomFormatScore(localEpisode.CustomFormats) ?? 0;

View file

@ -215,7 +215,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
{ {
DownloadClientItem downloadClientItem = null; DownloadClientItem downloadClientItem = null;
Series series = null; Series series = null;
TrackedDownload trackedDownload = null;
var directoryInfo = new DirectoryInfo(baseFolder); var directoryInfo = new DirectoryInfo(baseFolder);
@ -237,7 +236,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
if (downloadId.IsNotNullOrWhiteSpace()) if (downloadId.IsNotNullOrWhiteSpace())
{ {
trackedDownload = _trackedDownloadService.Find(downloadId); var trackedDownload = _trackedDownloadService.Find(downloadId);
downloadClientItem = trackedDownload.DownloadItem; downloadClientItem = trackedDownload.DownloadItem;
if (series == null) if (series == null)
@ -273,11 +272,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
var seriesFiles = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder).ToList()); var seriesFiles = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder).ToList());
var decisions = _importDecisionMaker.GetImportDecisions(seriesFiles, series, downloadClientItem, folderInfo, SceneSource(series, baseFolder), filterExistingFiles); 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(); return decisions.Select(decision => MapItem(decision, rootFolder, downloadId, directoryInfo.Name)).ToList();
} }
@ -337,10 +331,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
if (importDecisions.Any()) if (importDecisions.Any())
{ {
var importDecision = importDecisions.First(); return MapItem(importDecisions.First(), rootFolder, downloadId, null);
importDecision.LocalEpisode.IndexerFlags = trackedDownload?.RemoteEpisode?.Release?.IndexerFlags ?? 0;
return MapItem(importDecision, rootFolder, downloadId, null);
} }
} }
catch (Exception ex) catch (Exception ex)