Fixed: Add dedupe releases rule based on indexer priority

Closes #3925
This commit is contained in:
Bogdan 2023-07-26 11:36:59 +03:00
parent 0cfb3f1b63
commit dfd9440ee4
2 changed files with 12 additions and 3 deletions

View File

@ -166,8 +166,10 @@ namespace NzbDrone.Core.IndexerSearch
private List<DownloadDecision> DeDupeDecisions(List<DownloadDecision> decisions)
{
// De-dupe reports by guid so duplicate results aren't returned.
return decisions.DistinctBy(d => d.RemoteAlbum.Release.Guid).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.RemoteAlbum.Release.Guid)
.Select(d => d.OrderBy(v => v.Rejections.Count()).ThenBy(v => v.RemoteAlbum?.Release?.IndexerPriority ?? IndexerDefinition.DefaultPriority).First())
.ToList();
}
}
}

View File

@ -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;