From 3b042707f51216f06487bc268ee2f48950250413 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 31 Aug 2018 19:04:23 -0700 Subject: [PATCH] Interactive Season Search New: Interactive Season Search Fixed: BTN will no longer include season packs for individual episode searches --- .../BroadcastheNetRequestGenerator.cs | 15 +----------- src/Sonarr.Api.V3/Indexers/ReleaseModule.cs | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetRequestGenerator.cs b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetRequestGenerator.cs index 0dd19ab44..43fe683ca 100644 --- a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetRequestGenerator.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Collections.Generic; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -55,19 +55,6 @@ public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearch pageableRequests.Add(GetPagedRequests(MaxPages, parameters)); } - - if (searchCriteria.UserInvokedSearch) - { - foreach (var seasonNumber in searchCriteria.Episodes.Select(v => v.SeasonNumber).Distinct()) - { - parameters = parameters.Clone(); - - parameters.Category = "Season"; - parameters.Name = string.Format("Season {0}%", seasonNumber); - - pageableRequests.Add(GetPagedRequests(MaxPages, parameters)); - } - } } return pageableRequests; diff --git a/src/Sonarr.Api.V3/Indexers/ReleaseModule.cs b/src/Sonarr.Api.V3/Indexers/ReleaseModule.cs index 2ff2da8ce..d1a2dcbac 100644 --- a/src/Sonarr.Api.V3/Indexers/ReleaseModule.cs +++ b/src/Sonarr.Api.V3/Indexers/ReleaseModule.cs @@ -84,6 +84,11 @@ private List GetReleases() return GetEpisodeReleases(Request.Query.episodeId); } + if (Request.Query.seriesId.HasValue && Request.Query.seasonNumber.HasValue) + { + return GetSeasonReleases(Request.Query.seriesId, Request.Query.seasonNumber); + } + return GetRss(); } @@ -98,7 +103,24 @@ private List GetEpisodeReleases(int episodeId) } catch (Exception ex) { - _logger.ErrorException("Episode search failed: " + ex.Message, ex); + _logger.Error(ex, "Episode search failed: " + ex.Message); + } + + return new List(); + } + + private List GetSeasonReleases(int seriesId, int seasonNumber) + { + try + { + var decisions = _nzbSearchService.SeasonSearch(seriesId, seasonNumber, false, true, true); + var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions); + + return MapDecisions(prioritizedDecisions); + } + catch (Exception ex) + { + _logger.Error(ex, "Season search failed: " + ex.Message); } return new List();