From 39778a95bf65f1a34659c44cdc556aae5de6807a Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 29 Jul 2023 04:35:50 +0300 Subject: [PATCH] Dedupe releases based on indexer priority (cherry picked from commit 38c717bcef6fa5fcd2ff1c7901639eb888a94a8a) Closes #2727 --- src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs | 6 ++++-- src/NzbDrone.Core/Indexers/IndexerDefinition.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs index edcd34442..62d89ee47 100644 --- a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs @@ -165,8 +165,10 @@ namespace NzbDrone.Core.IndexerSearch private List DeDupeDecisions(List decisions) { - // De-dupe reports by guid so duplicate results aren't returned. Pick the one with the least rejections. - return decisions.GroupBy(d => d.RemoteBook.Release.Guid).Select(d => d.OrderBy(v => v.Rejections.Count()).First()).ToList(); + // De-dupe reports by guid so duplicate results aren't returned. Pick the one with the least rejections and higher indexer priority. + return decisions.GroupBy(d => d.RemoteBook.Release.Guid) + .Select(d => d.OrderBy(v => v.Rejections.Count()).ThenBy(v => v.RemoteBook?.Release?.IndexerPriority ?? IndexerDefinition.DefaultPriority).First()) + .ToList(); } } } diff --git a/src/NzbDrone.Core/Indexers/IndexerDefinition.cs b/src/NzbDrone.Core/Indexers/IndexerDefinition.cs index a6ed69130..50bea595b 100644 --- a/src/NzbDrone.Core/Indexers/IndexerDefinition.cs +++ b/src/NzbDrone.Core/Indexers/IndexerDefinition.cs @@ -4,6 +4,13 @@ namespace NzbDrone.Core.Indexers { public class IndexerDefinition : ProviderDefinition { + public const int DefaultPriority = 25; + + public IndexerDefinition() + { + Priority = DefaultPriority; + } + public bool EnableRss { get; set; } public bool EnableAutomaticSearch { get; set; } public bool EnableInteractiveSearch { get; set; } @@ -11,7 +18,7 @@ namespace NzbDrone.Core.Indexers public DownloadProtocol Protocol { get; set; } public bool SupportsRss { get; set; } public bool SupportsSearch { get; set; } - public int Priority { get; set; } = 25; + public int Priority { get; set; } public override bool Enable => EnableRss || EnableAutomaticSearch || EnableInteractiveSearch;