1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-29 03:05:49 +00:00
Sonarr/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs

45 lines
1.4 KiB
C#
Raw Normal View History

using System.Linq;
2013-04-07 07:30:37 +00:00
using NLog;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
2013-04-07 07:30:37 +00:00
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
{
public class SingleEpisodeSearchMatchSpecification : IDecisionEngineSearchSpecification
2013-04-07 07:30:37 +00:00
{
private readonly Logger _logger;
public SingleEpisodeSearchMatchSpecification(Logger logger)
2013-04-07 07:30:37 +00:00
{
_logger = logger;
}
public string RejectionReason
{
get
{
return "Episode doesn't match";
}
}
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchDefinitionBase searchDefinitionBase)
2013-04-07 07:30:37 +00:00
{
var singleEpisodeSpec = searchDefinitionBase as SingleEpisodeSearchDefinition;
if (singleEpisodeSpec == null) return true;
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)
2013-04-07 07:30:37 +00:00
{
_logger.Trace("Season number does not match searched season number, skipping.");
return false;
}
if (!remoteEpisode.Episodes.Select(c => c.EpisodeNumber).Contains(singleEpisodeSpec.EpisodeNumber))
2013-04-07 07:30:37 +00:00
{
_logger.Trace("Episode number does not match searched episode number, skipping.");
return false;
}
return true;
}
}
}