diff --git a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs index 63962502b..edcd34442 100644 --- a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs @@ -43,14 +43,26 @@ namespace NzbDrone.Core.IndexerSearch public List BookSearch(int bookId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { + var downloadDecisions = new List(); + var book = _bookService.GetBook(bookId); - return BookSearch(book, missingOnly, userInvokedSearch, interactiveSearch); + + var decisions = BookSearch(book, missingOnly, userInvokedSearch, interactiveSearch); + downloadDecisions.AddRange(decisions); + + return DeDupeDecisions(downloadDecisions); } public List AuthorSearch(int authorId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { + var downloadDecisions = new List(); + var author = _authorService.GetAuthor(authorId); - return AuthorSearch(author, missingOnly, userInvokedSearch, interactiveSearch); + + var decisions = AuthorSearch(author, missingOnly, userInvokedSearch, interactiveSearch); + downloadDecisions.AddRange(decisions); + + return DeDupeDecisions(downloadDecisions); } public List AuthorSearch(Author author, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) @@ -150,5 +162,11 @@ 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. 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(); + } } }