From 58d841c463854cc46d8feb6dfb1b784f4610b1a5 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 28 Oct 2023 15:31:17 -0700 Subject: [PATCH] Fixed: Searching for series with XEM and TVDB mapping overrides --- .../ReleaseSearchServiceFixture.cs | 40 +++++++++++++++++++ .../IndexerSearch/ReleaseSearchService.cs | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/ReleaseSearchServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/ReleaseSearchServiceFixture.cs index a2b77ab7d..522d92f9d 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/ReleaseSearchServiceFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/ReleaseSearchServiceFixture.cs @@ -568,5 +568,45 @@ namespace NzbDrone.Core.Test.IndexerSearchTests allCriteria.First().Should().BeOfType(); allCriteria.First().As().SeasonNumber.Should().Be(7); } + + [Test] + public async Task episode_search_should_use_all_available_numbering_from_services_and_xem() + { + WithEpisode(1, 12, 2, 3); + + Mocker.GetMock() + .Setup(s => s.FindByTvdbId(It.IsAny())) + .Returns(new List + { + new SceneMapping + { + TvdbId = _xemSeries.TvdbId, + SearchTerm = _xemSeries.Title, + ParseTerm = _xemSeries.Title, + FilterRegex = "(?i)-(BTN)$", + SeasonNumber = 1, + SceneSeasonNumber = 1, + SceneOrigin = "tvdb", + Type = "ServicesProvider" + } + }); + + var allCriteria = WatchForSearchCriteria(); + + await Subject.EpisodeSearch(_xemEpisodes.First(), false, false); + + Mocker.GetMock() + .Verify(v => v.FindByTvdbId(_xemSeries.Id), Times.Once()); + + allCriteria.Should().HaveCount(2); + + allCriteria.First().Should().BeOfType(); + allCriteria.First().As().SeasonNumber.Should().Be(1); + allCriteria.First().As().EpisodeNumber.Should().Be(12); + + allCriteria.Last().Should().BeOfType(); + allCriteria.Last().As().SeasonNumber.Should().Be(2); + allCriteria.Last().As().EpisodeNumber.Should().Be(3); + } } } diff --git a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs index de905efed..97420fb65 100644 --- a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs @@ -265,7 +265,7 @@ namespace NzbDrone.Core.IndexerSearch } } - if (sceneMapping.ParseTerm == series.CleanTitle && sceneMapping.FilterRegex.IsNotNullOrWhiteSpace()) + if (sceneMapping.ParseTerm == series.CleanTitle && sceneMapping.FilterRegex.IsNullOrWhiteSpace()) { // Disable the implied mapping if we have an explicit mapping by the same name includeGlobal = false;