From a6637b2911f7818e596c1518e94bd111cff0120b Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 15 Jan 2021 17:24:19 -0800 Subject: [PATCH] Fixed: Sorting in Interactive search duplicates results Closes #3964 --- .../IndexerSearch/NzbSearchService.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 743161a7d..3f3632ae1 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -151,7 +151,7 @@ namespace NzbDrone.Core.IndexerSearch } } - return downloadDecisions; + return DeDupeDecisions(downloadDecisions); } private List GetSceneSeasonMappings(Series series, List episodes) @@ -303,7 +303,7 @@ namespace NzbDrone.Core.IndexerSearch downloadDecisions.AddRange(decisions); } - return downloadDecisions; + return DeDupeDecisions(downloadDecisions); } private List SearchDaily(Series series, Episode episode, bool monitoredOnly, bool userInvokedSearch, bool interactiveSearch) @@ -362,7 +362,7 @@ namespace NzbDrone.Core.IndexerSearch downloadDecisions.AddRange(SearchSingle(series, episode, monitoredOnly, userInvokedSearch, interactiveSearch)); } - return downloadDecisions; + return DeDupeDecisions(downloadDecisions); } private List SearchAnimeSeason(Series series, List episodes, bool monitoredOnly, bool userInvokedSearch, bool interactiveSearch) @@ -381,7 +381,7 @@ namespace NzbDrone.Core.IndexerSearch downloadDecisions.AddRange(SearchAnime(series, episode, monitoredOnly, userInvokedSearch, interactiveSearch, true)); } - return downloadDecisions; + return DeDupeDecisions(downloadDecisions); } private List SearchDailySeason(Series series, List episodes, bool monitoredOnly, bool userInvokedSearch, bool interactiveSearch) @@ -412,7 +412,7 @@ namespace NzbDrone.Core.IndexerSearch } } - return downloadDecisions; + return DeDupeDecisions(downloadDecisions); } private TSpec Get(Series series, List episodes, bool monitoredOnly, bool userInvokedSearch, bool interactiveSearch) where TSpec : SearchCriteriaBase, new() @@ -520,5 +520,12 @@ namespace NzbDrone.Core.IndexerSearch return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList(); } + + private List DeDupeDecisions(List decisions) + { + // De-dupe reports by guid so duplicate results aren't returned. + + return decisions.DistinctBy(d => d.RemoteEpisode.Release.Guid).ToList(); + } } }