mirror of https://github.com/Sonarr/Sonarr
Fixed: Anime season searches rejecting season packs
This commit is contained in:
parent
d320017e3c
commit
e359347a3b
|
@ -0,0 +1,47 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.Search;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.Search.SingleEpisodeSearchMatchSpecificationTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AnimeSearchFixture : TestBase<SingleEpisodeSearchMatchSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode = new RemoteEpisode();
|
||||
private AnimeEpisodeSearchCriteria _searchCriteria = new AnimeEpisodeSearchCriteria();
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_full_season_result_for_single_episode_search()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.FullSeason = true;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_not_a_full_season_result()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.FullSeason = false;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_full_season_result_for_full_season_search()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.FullSeason = true;
|
||||
_searchCriteria.IsSeasonSearch = true;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.Search;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.Search.SingleEpisodeSearchMatchSpecificationTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class StandardEpisodeSearch : TestBase<SingleEpisodeSearchMatchSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode = new RemoteEpisode();
|
||||
private SingleEpisodeSearchCriteria _searchCriteria = new SingleEpisodeSearchCriteria();
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo();
|
||||
_remoteEpisode.ParsedEpisodeInfo.SeasonNumber = 5;
|
||||
_remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers = new[] { 1 };
|
||||
|
||||
_searchCriteria.SeasonNumber = 5;
|
||||
_searchCriteria.EpisodeNumber = 1;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_season_does_not_match()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.SeasonNumber = 10;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_full_season_result_for_single_episode_search()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers = Array.Empty<int>();
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_episode_number_does_not_match_search_criteria()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers = new []{ 2 };
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_full_season_result_for_full_season_search()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -281,6 +281,24 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
|
|||
criteria.Count.Should().Be(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void season_search_for_anime_should_set_isSeasonSearch_flag()
|
||||
{
|
||||
WithEpisodes();
|
||||
_xemSeries.SeriesType = SeriesTypes.Anime;
|
||||
_xemEpisodes.ForEach(e => e.EpisodeFileId = 0);
|
||||
|
||||
var seasonNumber = 1;
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true, true, false);
|
||||
|
||||
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(_xemEpisodes.Count(e => e.SeasonNumber == seasonNumber));
|
||||
criteria.ForEach(c => c.IsSeasonSearch.Should().BeTrue());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void season_search_for_daily_should_search_multiple_years()
|
||||
{
|
||||
|
|
|
@ -162,6 +162,8 @@
|
|||
<Compile Include="DecisionEngineTests\AnimeVersionUpgradeSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\RepackSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\MultiSeasonSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\Search\SingleEpisodeSearchMatchSpecificationTests\AnimeSearchFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\Search\SingleEpisodeSearchMatchSpecificationTests\StandardEpisodeSearch.cs" />
|
||||
<Compile Include="DecisionEngineTests\UpgradeAllowedSpecificationFixture .cs" />
|
||||
<Compile Include="DecisionEngineTests\FullSeasonSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\MaximumSizeSpecificationFixture.cs" />
|
||||
|
|
|
@ -56,9 +56,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|||
return Decision.Accept();
|
||||
}
|
||||
|
||||
private Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, AnimeEpisodeSearchCriteria singleEpisodeSpec)
|
||||
private Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, AnimeEpisodeSearchCriteria animeEpisodeSpec)
|
||||
{
|
||||
if (remoteEpisode.ParsedEpisodeInfo.FullSeason)
|
||||
if (remoteEpisode.ParsedEpisodeInfo.FullSeason && !animeEpisodeSpec.IsSeasonSearch)
|
||||
{
|
||||
_logger.Debug("Full season result during single episode search, skipping.");
|
||||
return Decision.Reject("Full season pack");
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
public class AnimeEpisodeSearchCriteria : SearchCriteriaBase
|
||||
{
|
||||
public int AbsoluteEpisodeNumber { get; set; }
|
||||
public bool IsSeasonSearch { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
|
@ -193,10 +193,12 @@ namespace NzbDrone.Core.IndexerSearch
|
|||
return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec);
|
||||
}
|
||||
|
||||
private List<DownloadDecision> SearchAnime(Series series, Episode episode, bool userInvokedSearch, bool interactiveSearch)
|
||||
private List<DownloadDecision> SearchAnime(Series series, Episode episode, bool userInvokedSearch, bool interactiveSearch, bool isSeasonSearch = false)
|
||||
{
|
||||
var searchSpec = Get<AnimeEpisodeSearchCriteria>(series, new List<Episode> { episode }, userInvokedSearch, interactiveSearch);
|
||||
|
||||
searchSpec.IsSeasonSearch = isSeasonSearch;
|
||||
|
||||
if (episode.SceneAbsoluteEpisodeNumber.HasValue)
|
||||
{
|
||||
searchSpec.AbsoluteEpisodeNumber = episode.SceneAbsoluteEpisodeNumber.Value;
|
||||
|
@ -232,7 +234,7 @@ namespace NzbDrone.Core.IndexerSearch
|
|||
// Only search for aired episodes when performing a season anime search
|
||||
foreach (var episode in episodes.Where(e => e.Monitored && e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow)))
|
||||
{
|
||||
downloadDecisions.AddRange(SearchAnime(series, episode, userInvokedSearch, interactiveSearch));
|
||||
downloadDecisions.AddRange(SearchAnime(series, episode, userInvokedSearch, interactiveSearch, true));
|
||||
}
|
||||
|
||||
return downloadDecisions;
|
||||
|
|
Loading…
Reference in New Issue