From b7e57f0c08f07dc86fe5424287058d5432a1acda Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 7 Oct 2023 03:09:44 +0300 Subject: [PATCH] Fixed: (Nebulance) Filter releases by season and episode for ID based searches --- .../Indexers/Definitions/Nebulance.cs | 21 +++++++++++++++++++ src/NzbDrone.Core/Indexers/IndexerBase.cs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs b/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs index f2bb6cee6..dba9ce9e4 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Net; using System.Text; using System.Text.Json.Serialization; @@ -67,6 +68,26 @@ namespace NzbDrone.Core.Indexers.Definitions return Task.FromResult(request); } + protected override IList CleanupReleases(IEnumerable releases, SearchCriteriaBase searchCriteria) + { + var cleanReleases = base.CleanupReleases(releases, searchCriteria); + + return FilterReleasesByQuery(cleanReleases, searchCriteria).ToList(); + } + + protected override IEnumerable FilterReleasesByQuery(IEnumerable releases, SearchCriteriaBase searchCriteria) + { + if (!searchCriteria.IsRssSearch && + searchCriteria.IsIdSearch && + searchCriteria is TvSearchCriteria tvSearchCriteria && + tvSearchCriteria.EpisodeSearchString.IsNotNullOrWhiteSpace()) + { + releases = releases.Where(r => r.Title.IsNotNullOrWhiteSpace() && r.Title.ContainsIgnoreCase(tvSearchCriteria.EpisodeSearchString)).ToList(); + } + + return releases; + } + private IndexerCapabilities SetCapabilities() { var caps = new IndexerCapabilities diff --git a/src/NzbDrone.Core/Indexers/IndexerBase.cs b/src/NzbDrone.Core/Indexers/IndexerBase.cs index 489bdbb27..2e2e7cdd9 100644 --- a/src/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/IndexerBase.cs @@ -149,7 +149,7 @@ namespace NzbDrone.Core.Indexers return result.DistinctBy(v => v.Guid).ToList(); } - protected IEnumerable FilterReleasesByQuery(IEnumerable releases, SearchCriteriaBase searchCriteria) + protected virtual IEnumerable FilterReleasesByQuery(IEnumerable releases, SearchCriteriaBase searchCriteria) { var commonWords = new[] { "and", "the", "an", "of" };