Skip to content

Commit

Permalink
Fixed: Add dedupe releases rule based on indexer priority
Browse files Browse the repository at this point in the history
Closes #3925
  • Loading branch information
mynameisbogdan committed Jul 29, 2023
1 parent 0cfb3f1 commit dfd9440
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs
Expand Up @@ -166,8 +166,10 @@ private List<DownloadDecision> Dispatch(Func<IIndexer, IEnumerable<ReleaseInfo>>

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();
}
}
}
9 changes: 8 additions & 1 deletion src/NzbDrone.Core/Indexers/IndexerDefinition.cs
Expand Up @@ -4,14 +4,21 @@ 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; }
public int DownloadClientId { get; set; }
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;

Expand Down

0 comments on commit dfd9440

Please sign in to comment.