public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { var queue = _queueService.GetQueue() .Select(q => q.RemoteEpisode).ToList(); var matchingSeries = queue.Where(q => q.Series.Id == subject.Series.Id); var matchingEpisode = matchingSeries.Where(q => q.Episodes.Select(e => e.Id).Intersect(subject.Episodes.Select(e => e.Id)).Any()); foreach (var remoteEpisode in matchingEpisode) { _logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, remoteEpisode.ParsedEpisodeInfo.Quality, subject.ParsedEpisodeInfo.Quality)) { return(Decision.Reject("Quality for release in queue already meets cutoff: {0}", remoteEpisode.ParsedEpisodeInfo.Quality)); } _logger.Debug("Checking if release is higher quality than queued release. Queued quality is: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, remoteEpisode.ParsedEpisodeInfo.Quality, subject.ParsedEpisodeInfo.Quality)) { return(Decision.Reject("Quality for release in queue is of equal or higher preference: {0}", remoteEpisode.ParsedEpisodeInfo.Quality)); } } return(Decision.Accept()); }
public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { _logger.Debug("Skipping history check during search"); return(Decision.Accept()); } var cdhEnabled = _configService.EnableCompletedDownloadHandling; _logger.Debug("Performing history status check on report"); _logger.Debug("Checking current status of episode [{0}] in history", subject.Movie.Id); var mostRecent = _historyService.MostRecentForMovie(subject.Movie.Id); if (mostRecent != null && mostRecent.EventType == HistoryEventType.Grabbed) { var recent = mostRecent.Date.After(DateTime.UtcNow.AddHours(-12)); var cutoffUnmet = _qualityUpgradableSpecification.CutoffNotMet(subject.Movie.Profile, mostRecent.Quality, subject.ParsedMovieInfo.Quality); var upgradeable = _qualityUpgradableSpecification.IsUpgradable(subject.Movie.Profile, mostRecent.Quality, subject.ParsedMovieInfo.Quality); if (!recent && cdhEnabled) { return(Decision.Accept()); } if (!cutoffUnmet) { if (recent) { return(Decision.Reject("Recent grab event in history already meets cutoff: {0}", mostRecent.Quality)); } return(Decision.Reject("CDH is disabled and grab event in history already meets cutoff: {0}", mostRecent.Quality)); } if (!upgradeable) { if (recent) { return(Decision.Reject("Recent grab event in history is of equal or higher quality: {0}", mostRecent.Quality)); } return(Decision.Reject("CDH is disabled and grab event in history is of equal or higher quality: {0}", mostRecent.Quality)); } } return(Decision.Accept()); }
public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) { _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) { _logger.Debug("Cutoff already met, rejecting."); return(Decision.Reject("Existing file meets cutoff: {0}", subject.Series.Profile.Value.Cutoff)); } } return(Decision.Accept()); }
public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { if (subject.Movie.MovieFile != null) { if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Movie.Profile, subject.Movie.MovieFile.Quality, subject.ParsedMovieInfo.Quality)) { return(Decision.Reject("Existing file meets cutoff: {0}", subject.Movie.Profile.Value.Cutoff)); } } return(Decision.Accept()); }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) { _logger.Trace("Comparing file quality with report. Existing file is {0}", file.Quality); if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.QualityProfile, file.Quality, subject.ParsedEpisodeInfo.Quality)) { return(false); } } return(true); }