From 200aee52f788bba3d90564d4d4ca5bcd3626e713 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Fri, 17 Apr 2020 00:24:07 +0200 Subject: [PATCH] New: Searching for episodes with season level scene mapping now possible instead of only via RssSync (Newznab/Torznab only) --- frontend/src/Episode/SceneInfo.js | 5 ++ .../StandardEpisodeSearch.cs | 35 ++++++++++++- .../ParsingServiceTests/GetEpisodesFixture.cs | 8 ++- .../ParsingServiceTests/MapFixture.cs | 4 ++ .../Scene/SceneMappingService.cs | 38 +++++++++++++- .../DecisionEngine/DownloadDecisionMaker.cs | 2 +- .../Search/SeasonMatchSpecification.cs | 11 ++++- .../SingleEpisodeSearchMatchSpecification.cs | 11 ++++- .../Definitions/SearchCriteriaBase.cs | 2 + .../IndexerSearch/NzbSearchService.cs | 3 ++ .../Indexers/IndexerPageableRequestChain.cs | 7 +++ .../Newznab/NewznabRequestGenerator.cs | 49 ++++++++++++++----- src/NzbDrone.Core/Parser/ParsingService.cs | 10 ++-- 13 files changed, 158 insertions(+), 27 deletions(-) diff --git a/frontend/src/Episode/SceneInfo.js b/frontend/src/Episode/SceneInfo.js index 3eef9351f..ed42f8bdf 100644 --- a/frontend/src/Episode/SceneInfo.js +++ b/frontend/src/Episode/SceneInfo.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import padNumber from 'Utilities/Number/padNumber'; import styles from './SceneInfo.css'; function SceneInfo(props) { @@ -60,6 +61,10 @@ function SceneInfo(props) { key={alternateTitle.title} > {alternateTitle.title} + { + alternateTitle.sceneSeasonNumber !== -1 && + (S{padNumber(alternateTitle.sceneSeasonNumber, 2)}) + } ); }) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SingleEpisodeSearchMatchSpecificationTests/StandardEpisodeSearch.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SingleEpisodeSearchMatchSpecificationTests/StandardEpisodeSearch.cs index 993c2c936..671d794e6 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SingleEpisodeSearchMatchSpecificationTests/StandardEpisodeSearch.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SingleEpisodeSearchMatchSpecificationTests/StandardEpisodeSearch.cs @@ -1,6 +1,8 @@ using System; using FluentAssertions; +using Moq; using NUnit.Framework; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine.Specifications.Search; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -23,6 +25,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search.SingleEpisodeSearchMatch _searchCriteria.SeasonNumber = 5; _searchCriteria.EpisodeNumber = 1; + + Mocker.GetMock() + .Setup(v => v.GetTvdbSeasonNumber(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns((s, r, i) => i); + } + + private void GivenMapping(int sceneSeasonNumber, int seasonNumber) + { + Mocker.GetMock() + .Setup(v => v.GetTvdbSeasonNumber(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns((s, r, i) => i >= sceneSeasonNumber ? (seasonNumber + i - sceneSeasonNumber) : i); } [Test] @@ -33,6 +46,26 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search.SingleEpisodeSearchMatch Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse(); } + [Test] + public void should_return_true_if_season_matches_after_scenemapping() + { + _remoteEpisode.ParsedEpisodeInfo.SeasonNumber = 10; + + GivenMapping(10, 5); + + Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeTrue(); + } + + [Test] + public void should_return_false_if_season_does_not_match_after_scenemapping() + { + _remoteEpisode.ParsedEpisodeInfo.SeasonNumber = 10; + + GivenMapping(9, 5); + + Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse(); + } + [Test] public void should_return_false_if_full_season_result_for_single_episode_search() { @@ -44,7 +77,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search.SingleEpisodeSearchMatch [Test] public void should_return_false_if_episode_number_does_not_match_search_criteria() { - _remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers = new []{ 2 }; + _remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers = new[] { 2 }; Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse(); } diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetEpisodesFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetEpisodesFixture.cs index dec49dfe8..bfe87a693 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetEpisodesFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetEpisodesFixture.cs @@ -55,6 +55,10 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests Mocker.GetMock() .Setup(s => s.FindByTitle(It.IsAny())) .Returns(_series); + + Mocker.GetMock() + .Setup(v => v.GetTvdbSeasonNumber(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns((s, r, i) => i); } private void GivenDailySeries() @@ -324,8 +328,8 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests const int tvdbSeasonNumber = 5; Mocker.GetMock() - .Setup(s => s.FindSceneMapping(_parsedEpisodeInfo.SeriesTitle, It.IsAny())) - .Returns(new SceneMapping { SeasonNumber = tvdbSeasonNumber, SceneSeasonNumber = _parsedEpisodeInfo.SeasonNumber }); + .Setup(v => v.GetTvdbSeasonNumber(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns((s, r, i) => tvdbSeasonNumber); Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null); diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs index cce11375d..3f62300f3 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs @@ -51,6 +51,10 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests SeasonNumber = _episodes.First().SeasonNumber, Episodes = _episodes }; + + Mocker.GetMock() + .Setup(v => v.GetTvdbSeasonNumber(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns((s, r, i) => i); } private void GivenMatchBySeriesTitle() diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs index 72739009f..2bb9af045 100644 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs +++ b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs @@ -15,11 +15,13 @@ namespace NzbDrone.Core.DataAugmentation.Scene public interface ISceneMappingService { List GetSceneNames(int tvdbId, List seasonNumbers, List sceneSeasonNumbers); + List GetSceneMappings(int tvdbId, List seasonNumbers); int? FindTvdbId(string sceneTitle, string releaseTitle); List FindByTvdbId(int tvdbId); SceneMapping FindSceneMapping(string sceneTitle, string releaseTitle); int? GetSceneSeasonNumber(string seriesTitle, string releaseTitle); int? GetTvdbSeasonNumber(string seriesTitle, string releaseTitle); + int GetTvdbSeasonNumber(string seriesTitle, string releaseTitle, int sceneSeasonNumber); int? GetSceneSeasonNumber(int tvdbId, int seasonNumber); } @@ -66,6 +68,21 @@ namespace NzbDrone.Core.DataAugmentation.Scene return FilterNonEnglish(names); } + public List GetSceneMappings(int tvdbId, List seasonNumbers) + { + var mappings = FindByTvdbId(tvdbId); + + if (mappings == null) + { + return new List(); + } + + return mappings.Where(n => seasonNumbers.Contains(n.SeasonNumber ?? -1) && + (n.SceneSeasonNumber ?? -1) != -1) + .Where(n => IsEnglish(n.SearchTerm)) + .ToList(); + } + public int? FindTvdbId(string seriesTitle) { return FindTvdbId(seriesTitle, null); @@ -129,6 +146,20 @@ namespace NzbDrone.Core.DataAugmentation.Scene return FindSceneMapping(seriesTitle, releaseTitle)?.SeasonNumber; } + public int GetTvdbSeasonNumber(string seriesTitle, string releaseTitle, int sceneSeasonNumber) + { + var sceneMapping = FindSceneMapping(seriesTitle, releaseTitle); + + if (sceneMapping != null && sceneMapping.SeasonNumber.HasValue && sceneMapping.SeasonNumber.Value >= 0 && + sceneMapping.SceneSeasonNumber <= sceneSeasonNumber) + { + var offset = sceneSeasonNumber - sceneMapping.SceneSeasonNumber.Value; + return sceneMapping.SeasonNumber.Value + offset; + } + + return sceneSeasonNumber; + } + public int? GetSceneSeasonNumber(int tvdbId, int seasonNumber) { var mappings = FindByTvdbId(tvdbId); @@ -266,7 +297,12 @@ namespace NzbDrone.Core.DataAugmentation.Scene private List FilterNonEnglish(List titles) { - return titles.Where(title => title.All(c => c <= 255)).ToList(); + return titles.Where(IsEnglish).ToList(); + } + + private bool IsEnglish(string title) + { + return title.All(c => c <= 255); } public void Handle(SeriesRefreshStartingEvent message) diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 286fac520..69a28e53f 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -104,7 +104,7 @@ namespace NzbDrone.Core.DecisionEngine } else if (remoteEpisode.Episodes.Empty()) { - decision = new DownloadDecision(remoteEpisode, new Rejection("Unable to parse episodes from release name")); + decision = new DownloadDecision(remoteEpisode, new Rejection("Unable to identify correct episode(s) using release name and scene mappings")); } else { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs index 8516b08e7..a8bca8c0e 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs @@ -1,4 +1,5 @@ using NLog; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -7,10 +8,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search public class SeasonMatchSpecification : IDecisionEngineSpecification { private readonly Logger _logger; + private readonly ISceneMappingService _sceneMappingService; - public SeasonMatchSpecification(Logger logger) + public SeasonMatchSpecification(ISceneMappingService sceneMappingService, Logger logger) { _logger = logger; + _sceneMappingService = sceneMappingService; } public SpecificationPriority Priority => SpecificationPriority.Default; @@ -26,7 +29,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search var singleEpisodeSpec = searchCriteria as SeasonSearchCriteria; if (singleEpisodeSpec == null) return Decision.Accept(); - if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) + var seasonNumber = _sceneMappingService.GetTvdbSeasonNumber(remoteEpisode.ParsedEpisodeInfo.SeriesTitle, + remoteEpisode.ParsedEpisodeInfo.ReleaseTitle, + remoteEpisode.ParsedEpisodeInfo.SeasonNumber); + + if (singleEpisodeSpec.SeasonNumber != seasonNumber) { _logger.Debug("Season number does not match searched season number, skipping."); return Decision.Reject("Wrong season"); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs index fc9b0b895..d888cb522 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs @@ -1,5 +1,6 @@ using System.Linq; using NLog; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -8,10 +9,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search public class SingleEpisodeSearchMatchSpecification : IDecisionEngineSpecification { private readonly Logger _logger; + private readonly ISceneMappingService _sceneMappingService; - public SingleEpisodeSearchMatchSpecification(Logger logger) + public SingleEpisodeSearchMatchSpecification(ISceneMappingService sceneMappingService, Logger logger) { _logger = logger; + _sceneMappingService = sceneMappingService; } public SpecificationPriority Priority => SpecificationPriority.Default; @@ -35,7 +38,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search private Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SingleEpisodeSearchCriteria singleEpisodeSpec) { - if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) + var seasonNumber = _sceneMappingService.GetTvdbSeasonNumber(remoteEpisode.ParsedEpisodeInfo.SeriesTitle, + remoteEpisode.ParsedEpisodeInfo.ReleaseTitle, + remoteEpisode.ParsedEpisodeInfo.SeasonNumber); + + if (singleEpisodeSpec.SeasonNumber != seasonNumber) { _logger.Debug("Season number does not match searched season number, skipping."); return Decision.Reject("Wrong season"); diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs index 837dcc4b2..dc2a4cdaf 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text.RegularExpressions; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Extensions; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Tv; namespace NzbDrone.Core.IndexerSearch.Definitions @@ -15,6 +16,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public Series Series { get; set; } public List SceneTitles { get; set; } + public List SceneMappings { get; set; } public List Episodes { get; set; } public virtual bool MonitoredEpisodesOnly { get; set; } public virtual bool UserInvokedSearch { get; set; } diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 7937c7b8b..dad706cc6 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -280,6 +280,9 @@ namespace NzbDrone.Core.IndexerSearch spec.SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId, episodes.Select(e => e.SeasonNumber).Distinct().ToList(), episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList()); + spec.SceneMappings = _sceneMapping.GetSceneMappings(series.TvdbId, + episodes.Select(e => e.SeasonNumber).Distinct().ToList()); + if (!spec.SceneTitles.Contains(series.Title)) { diff --git a/src/NzbDrone.Core/Indexers/IndexerPageableRequestChain.cs b/src/NzbDrone.Core/Indexers/IndexerPageableRequestChain.cs index b44cfaf76..43b6b2277 100644 --- a/src/NzbDrone.Core/Indexers/IndexerPageableRequestChain.cs +++ b/src/NzbDrone.Core/Indexers/IndexerPageableRequestChain.cs @@ -32,6 +32,13 @@ namespace NzbDrone.Core.Indexers _chains.Last().Add(new IndexerPageableRequest(request)); } + public void AddToTier(int tierIndex, IEnumerable request) + { + if (request == null) return; + + _chains[tierIndex].Add(new IndexerPageableRequest(request)); + } + public void AddTier(IEnumerable request) { AddTier(); diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index 57b055bda..02aea8aad 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -1,7 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.IndexerSearch.Definitions; namespace NzbDrone.Core.Indexers.Newznab @@ -128,11 +130,16 @@ namespace NzbDrone.Core.Indexers.Newznab { var pageableRequests = new IndexerPageableRequestChain(); - AddTvIdPageableRequests(pageableRequests, MaxPages, Settings.Categories, searchCriteria, + AddTvIdPageableRequests(pageableRequests, Settings.Categories, searchCriteria, string.Format("&season={0}&ep={1}", searchCriteria.SeasonNumber, searchCriteria.EpisodeNumber)); + AddSceneTitlePageableRequests(pageableRequests, Settings.Categories, searchCriteria, + m => string.Format("&season={0}&ep={1}", + m.SceneSeasonNumber, + searchCriteria.EpisodeNumber)); + return pageableRequests; } @@ -140,10 +147,14 @@ namespace NzbDrone.Core.Indexers.Newznab { var pageableRequests = new IndexerPageableRequestChain(); - AddTvIdPageableRequests(pageableRequests, MaxPages, Settings.Categories, searchCriteria, + AddTvIdPageableRequests(pageableRequests, Settings.Categories, searchCriteria, string.Format("&season={0}", searchCriteria.SeasonNumber)); + AddSceneTitlePageableRequests(pageableRequests, Settings.Categories, searchCriteria, + m => string.Format("&season={0}", + m.SceneSeasonNumber)); + return pageableRequests; } @@ -151,7 +162,7 @@ namespace NzbDrone.Core.Indexers.Newznab { var pageableRequests = new IndexerPageableRequestChain(); - AddTvIdPageableRequests(pageableRequests, MaxPages, Settings.Categories, searchCriteria, + AddTvIdPageableRequests(pageableRequests, Settings.Categories, searchCriteria, string.Format("&season={0:yyyy}&ep={0:MM}/{0:dd}", searchCriteria.AirDate)); @@ -162,7 +173,7 @@ namespace NzbDrone.Core.Indexers.Newznab { var pageableRequests = new IndexerPageableRequestChain(); - AddTvIdPageableRequests(pageableRequests, MaxPages, Settings.Categories, searchCriteria, + AddTvIdPageableRequests(pageableRequests, Settings.Categories, searchCriteria, string.Format("&season={0}", searchCriteria.Year)); @@ -207,7 +218,7 @@ namespace NzbDrone.Core.Indexers.Newznab return pageableRequests; } - private void AddTvIdPageableRequests(IndexerPageableRequestChain chain, int maxPages, IEnumerable categories, SearchCriteriaBase searchCriteria, string parameters) + private void AddTvIdPageableRequests(IndexerPageableRequestChain chain, IEnumerable categories, SearchCriteriaBase searchCriteria, string parameters) { var includeTvdbSearch = SupportsTvdbSearch && searchCriteria.Series.TvdbId > 0; var includeImdbSearch = SupportsImdbSearch && searchCriteria.Series.ImdbId.IsNotNullOrWhiteSpace(); @@ -237,29 +248,29 @@ namespace NzbDrone.Core.Indexers.Newznab ids += "&tvmazeid=" + searchCriteria.Series.TvMazeId; } - chain.Add(GetPagedRequests(maxPages, categories, "tvsearch", ids + parameters)); + chain.Add(GetPagedRequests(MaxPages, categories, "tvsearch", ids + parameters)); } else { if (includeTvdbSearch) { - chain.Add(GetPagedRequests(maxPages, categories, "tvsearch", + chain.Add(GetPagedRequests(MaxPages, categories, "tvsearch", string.Format("&tvdbid={0}{1}", searchCriteria.Series.TvdbId, parameters))); } else if (includeImdbSearch) { - chain.Add(GetPagedRequests(maxPages, categories, "tvsearch", + chain.Add(GetPagedRequests(MaxPages, categories, "tvsearch", string.Format("&imdbid={0}{1}", searchCriteria.Series.ImdbId, parameters))); } else if (includeTvRageSearch) { - chain.Add(GetPagedRequests(maxPages, categories, "tvsearch", + chain.Add(GetPagedRequests(MaxPages, categories, "tvsearch", string.Format("&rid={0}{1}", searchCriteria.Series.TvRageId, parameters))); } else if (includeTvMazeSearch) { - chain.Add(GetPagedRequests(maxPages, categories, "tvsearch", + chain.Add(GetPagedRequests(MaxPages, categories, "tvsearch", string.Format("&tvmazeid={0}{1}", searchCriteria.Series.TvMazeId, parameters))); } } @@ -277,6 +288,22 @@ namespace NzbDrone.Core.Indexers.Newznab } } + private void AddSceneTitlePageableRequests(IndexerPageableRequestChain chain, IEnumerable categories, SearchCriteriaBase searchCriteria, Func parametersFunc) + { + foreach (var sceneMappingGroup in searchCriteria.SceneMappings.GroupBy(v => v.SceneSeasonNumber)) + { + var parameters = parametersFunc(sceneMappingGroup.First()); + + foreach (var searchTerm in sceneMappingGroup.Select(v => v.SearchTerm).Distinct()) + { + chain.AddToTier(0, GetPagedRequests(MaxPages, Settings.Categories, "tvsearch", + string.Format("&q={0}{1}", + NewsnabifyTitle(searchTerm), + parameters))); + } + } + } + private IEnumerable GetPagedRequests(int maxPages, IEnumerable categories, string searchType, string parameters) { if (categories.Empty()) diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index e357cc0c4..fc9b28b35 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -402,13 +402,9 @@ namespace NzbDrone.Core.Parser if (sceneSource) { - var sceneMapping = _sceneMappingService.FindSceneMapping(parsedEpisodeInfo.SeriesTitle, parsedEpisodeInfo.ReleaseTitle); - - if (sceneMapping != null && sceneMapping.SeasonNumber.HasValue && sceneMapping.SeasonNumber.Value >= 0 && - sceneMapping.SceneSeasonNumber == seasonNumber) - { - seasonNumber = sceneMapping.SeasonNumber.Value; - } + seasonNumber = _sceneMappingService.GetTvdbSeasonNumber(parsedEpisodeInfo.SeriesTitle, + parsedEpisodeInfo.ReleaseTitle, + parsedEpisodeInfo.SeasonNumber); } if (parsedEpisodeInfo.EpisodeNumbers == null)