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(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.IsUpgradable(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) { return(Decision.Reject("Quality for existing file on disk is of equal or higher preference: {0}", file.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 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.IsUpgradable(file.Quality, subject.ParsedEpisodeInfo.Quality)) { return(false); } } return(true); }
public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { if (subject.Movie.MovieFile == null) { return(Decision.Accept()); } var file = subject.Movie.MovieFile; _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); if (!_qualityUpgradableSpecification.IsUpgradable(subject.Movie.Profile, file.Quality, subject.ParsedMovieInfo.Quality)) { return(Decision.Reject("Quality for existing file on disk is of equal or higher preference: {0}", file.Quality)); } return(Decision.Accept()); }
public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { _logger.Debug("Skipping history check during search"); return(Decision.Accept()); } var downloadClients = _downloadClientProvider.GetDownloadClients(); foreach (var downloadClient in downloadClients.OfType <Sabnzbd>()) { _logger.Debug("Performing history status check on report"); foreach (var episode in subject.Episodes) { _logger.Debug("Checking current status of episode [{0}] in history", episode.Id); var mostRecent = _historyService.MostRecentForEpisode(episode.Id); if (mostRecent != null && mostRecent.EventType == HistoryEventType.Grabbed) { _logger.Debug("Latest history item is downloading, rejecting."); return(Decision.Reject("Download has not been imported yet")); } } return(Decision.Accept()); } foreach (var episode in subject.Episodes) { var bestQualityInHistory = _historyService.GetBestQualityInHistory(subject.Series.Profile, episode.Id); if (bestQualityInHistory != null) { _logger.Debug("Comparing history quality with report. History is {0}", bestQualityInHistory); if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, bestQualityInHistory, subject.ParsedEpisodeInfo.Quality)) { return(Decision.Reject("Existing file in history is of equal or higher quality: {0}", bestQualityInHistory)); } } } return(Decision.Accept()); }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { _logger.Debug("Skipping history check during search"); return(true); } var downloadClient = _downloadClientProvider.GetDownloadClient(); if (downloadClient != null && downloadClient.GetType() == typeof(Sabnzbd)) { _logger.Debug("Performing history status check on report"); foreach (var episode in subject.Episodes) { _logger.Debug("Checking current status of episode [{0}] in history", episode.Id); var mostRecent = _historyService.MostRecentForEpisode(episode.Id); if (mostRecent != null && mostRecent.EventType == HistoryEventType.Grabbed) { _logger.Debug("Latest history item is downloading, rejecting."); return(false); } } return(true); } foreach (var episode in subject.Episodes) { var bestQualityInHistory = _historyService.GetBestQualityInHistory(subject.Series.QualityProfile, episode.Id); if (bestQualityInHistory != null) { _logger.Debug("Comparing history quality with report. History is {0}", bestQualityInHistory); if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.QualityProfile, bestQualityInHistory, subject.ParsedEpisodeInfo.Quality)) { return(false); } } } return(true); }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { _logger.Trace("Skipping history check during search"); return(true); } foreach (var episode in subject.Episodes) { var bestQualityInHistory = _historyService.GetBestQualityInHistory(episode.Id); if (bestQualityInHistory != null) { _logger.Trace("Comparing history quality with report. History is {0}", bestQualityInHistory); if (!_qualityUpgradableSpecification.IsUpgradable(bestQualityInHistory, subject.ParsedEpisodeInfo.Quality)) { return(false); } } } return(true); }