Skip to content

Commit

Permalink
Dedupe releases based on indexer priority
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Jul 29, 2023
1 parent 3d6cf24 commit 38c717b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs
Expand Up @@ -548,9 +548,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. Pick the one with the least rejections.

return decisions.GroupBy(d => d.RemoteEpisode.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.RemoteEpisode.Release.Guid)
.Select(d => d.OrderBy(v => v.Rejections.Count()).ThenBy(v => v.RemoteEpisode?.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 int SeasonSearchMaximumSingleEpisodeAge { get; set; }

public override bool Enable => EnableRss || EnableAutomaticSearch || EnableInteractiveSearch;
Expand Down

0 comments on commit 38c717b

Please sign in to comment.