public bool IsUpgradeAllowed(QualityProfile qualityProfile, LanguageProfile languageProfile, QualityModel currentQuality, Language currentLanguage, QualityModel newQuality, Language newLanguage) { var isQualityUpgrade = new QualityModelComparer(qualityProfile).Compare(newQuality, currentQuality) > 0; var isLanguageUpgrade = new LanguageComparer(languageProfile).Compare(newLanguage, currentLanguage) > 0; if (isQualityUpgrade && qualityProfile.UpgradeAllowed || isLanguageUpgrade && languageProfile.UpgradeAllowed) { _logger.Debug("At least one profile allows upgrading"); return(true); } if (isQualityUpgrade && !qualityProfile.UpgradeAllowed) { _logger.Debug("Quality profile does not allow upgrades, skipping"); return(false); } if (isLanguageUpgrade && !languageProfile.UpgradeAllowed) { _logger.Debug("Language profile does not allow upgrades, skipping"); return(false); } return(true); }
public Decision IsSatisfiedBy(LocalBook item, DownloadClientItem downloadClientItem) { var files = item.Book?.BookFiles?.Value; if (files == null || !files.Any()) { // No existing books, skip. This guards against new authors not having a QualityProfile. return(Decision.Accept()); } var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks; var qualityComparer = new QualityModelComparer(item.Author.QualityProfile); foreach (var bookFile in files) { var qualityCompare = qualityComparer.Compare(item.Quality.Quality, bookFile.Quality.Quality); if (qualityCompare < 0) { _logger.Debug("This file isn't a quality upgrade for all books. Skipping {0}", item.Path); return(Decision.Reject("Not an upgrade for existing book file(s)")); } if (qualityCompare == 0 && downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && item.Quality.Revision.CompareTo(bookFile.Quality.Revision) < 0) { _logger.Debug("This file isn't a quality upgrade for all books. Skipping {0}", item.Path); return(Decision.Reject("Not an upgrade for existing book file(s)")); } } return(Decision.Accept()); }
public Decision IsSatisfiedBy(LocalTrack localTrack) { var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks; var qualityComparer = new QualityModelComparer(localTrack.Artist.QualityProfile); foreach (var track in localTrack.Tracks.Where(e => e.TrackFileId > 0)) { var trackFile = track.TrackFile.Value; var qualityCompare = qualityComparer.Compare(localTrack.Quality.Quality, trackFile.Quality.Quality); if (qualityCompare < 0) { _logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", localTrack.Path); return(Decision.Reject("Not an upgrade for existing track file(s)")); } if (qualityCompare == 0 && downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && localTrack.Quality.Revision.CompareTo(trackFile.Quality.Revision) < 0) { _logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", localTrack.Path); return(Decision.Reject("Not an upgrade for existing track file(s)")); } } return(Decision.Accept()); }
private void RemoveGrabbed(RemoteEpisode remoteEpisode) { var pendingReleases = GetPendingReleases(); var episodeIds = remoteEpisode.Episodes.Select(e => e.Id); var existingReports = pendingReleases.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id) .Intersect(episodeIds) .Any()) .ToList(); if (existingReports.Empty()) { return; } var profile = remoteEpisode.Series.Profile.Value; foreach (var existingReport in existingReports) { var compare = new QualityModelComparer(profile).Compare(remoteEpisode.ParsedEpisodeInfo.Quality, existingReport.RemoteEpisode.ParsedEpisodeInfo.Quality); //Only remove lower/equal quality pending releases //It is safer to retry these releases on the next round than remove it and try to re-add it (if its still in the feed) if (compare >= 0) { _logger.Debug("Removing previously pending release, as it was grabbed."); Delete(existingReport); } } }
private ProfileComparisonResult IsQualityUpgradable(QualityProfile profile, List <QualityModel> currentQualities, QualityModel newQuality = null) { if (newQuality != null) { var totalCompare = 0; foreach (var quality in currentQualities) { var compare = new QualityModelComparer(profile).Compare(newQuality, quality); totalCompare += compare; if (compare < 0) { // Not upgradable if new quality is a downgrade for any current quality return(ProfileComparisonResult.Downgrade); } } // Not upgradable if new quality is equal to all current qualities if (totalCompare == 0) { return(ProfileComparisonResult.Equal); } // Quality Treated as Equal if Propers are not Prefered if (_configService.DownloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer && newQuality.Revision.CompareTo(currentQualities.Min(q => q.Revision)) > 0) { return(ProfileComparisonResult.Equal); } } return(ProfileComparisonResult.Upgrade); }
public bool IsUpgradable(QualityProfile qualityProfile, LanguageProfile languageProfile, QualityModel currentQuality, Language currentLanguage, int currentScore, QualityModel newQuality, Language newLanguage, int newScore) { var qualityComparer = new QualityModelComparer(qualityProfile); var qualityCompare = qualityComparer.Compare(newQuality?.Quality, currentQuality.Quality); var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks; if (qualityCompare > 0) { _logger.Debug("New item has a better quality"); return(true); } if (qualityCompare < 0) { _logger.Debug("Existing item has better quality, skipping"); return(false); } var qualityRevisionComapre = newQuality?.Revision.CompareTo(currentQuality.Revision); // Accept unless the user doesn't want to prefer propers, optionally they can // use preferred words to prefer propers/repacks over non-propers/repacks. if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && qualityRevisionComapre > 0) { _logger.Debug("New item has a better quality revision"); return(true); } // Reject unless the user does not prefer propers/repacks and it's a revision downgrade. if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && qualityRevisionComapre < 0) { _logger.Debug("Existing item has a better quality revision, skipping"); return(false); } var languageCompare = new LanguageComparer(languageProfile).Compare(newLanguage, currentLanguage); if (languageCompare > 0) { _logger.Debug("New item has a more preferred language"); return(true); } if (languageCompare < 0) { _logger.Debug("Existing item has better language, skipping"); return(false); } if (!IsPreferredWordUpgradable(currentScore, newScore)) { _logger.Debug("Existing item has an equal or better preferred word score, skipping"); return(false); } _logger.Debug("New item has a better preferred word score"); return(true); }
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) { var qualityComparer = new QualityModelComparer(localMovie.Movie.Profile); if (localMovie.Movie.MovieFileId > 0) { var movieFile = localMovie.Movie.MovieFile; if (movieFile == null) { _logger.Trace("Unable to get movie file details from the DB. MovieId: {0} MovieFileId: {1}", localMovie.Movie.Id, localMovie.Movie.MovieFileId); return(Decision.Accept()); } var qualityCompare = qualityComparer.Compare(localMovie.Quality.Quality, movieFile.Quality.Quality); if (qualityCompare < 0) { _logger.Debug("This file isn't a quality upgrade for movie. Skipping {0}", localMovie.Path); return(Decision.Reject("Not an upgrade for existing movie file(s)")); } } return(Decision.Accept()); }
private ProfileComparisonResult IsQualityUpgradable(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null) { if (newQuality != null) { var totalCompare = 0; var compare = new QualityModelComparer(profile).Compare(newQuality, currentQuality); totalCompare += compare; if (compare < 0) { // Not upgradable if new quality is a downgrade for any current quality return(ProfileComparisonResult.Downgrade); } // Not upgradable if new quality is equal to all current qualities if (totalCompare == 0) { return(ProfileComparisonResult.Equal); } // Accept unless the user doesn't want to prefer propers, optionally they can // use preferred words to prefer propers/repacks over non-propers/repacks. if (_configService.DownloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer && newQuality?.Revision.CompareTo(currentQuality.Revision) > 0) { return(ProfileComparisonResult.Equal); } } return(ProfileComparisonResult.Upgrade); }
public QualityModel GetBestQualityInHistory(Profile profile, int movieId) { var comparer = new QualityModelComparer(profile); return _historyRepository.GetBestQualityInHistory(movieId) .OrderByDescending(q => q, comparer) .FirstOrDefault(); }
public Decision IsSatisfiedBy(LocalAlbumRelease localAlbumRelease) { var artist = localAlbumRelease.AlbumRelease.Album.Value.Artist.Value; var qualityComparer = new QualityModelComparer(artist.QualityProfile); // check if we are changing release var currentRelease = localAlbumRelease.AlbumRelease.Album.Value.AlbumReleases.Value.Single(x => x.Monitored); var newRelease = localAlbumRelease.AlbumRelease; // if we are, check we are upgrading if (newRelease.Id != currentRelease.Id) { // min quality of all new tracks var newMinQuality = localAlbumRelease.LocalTracks.Select(x => x.Quality).OrderBy(x => x, qualityComparer).First(); _logger.Debug("Min quality of new files: {0}", newMinQuality); // get minimum quality of existing release var existingQualities = currentRelease.Tracks.Value.Where(x => x.TrackFileId != 0).Select(x => x.TrackFile.Value.Quality); if (existingQualities.Any()) { var existingMinQuality = existingQualities.OrderBy(x => x, qualityComparer).First(); _logger.Debug("Min quality of existing files: {0}", existingMinQuality); if (qualityComparer.Compare(existingMinQuality, newMinQuality) > 0) { _logger.Debug("This album isn't a quality upgrade for all tracks. Skipping {0}", localAlbumRelease); return(Decision.Reject("Not an upgrade for existing album file(s)")); } } } return(Decision.Accept()); }
public QualityModel GetBestQualityInHistory(QualityProfile qualityProfile, int episodeId) { var comparer = new QualityModelComparer(qualityProfile); return(_historyRepository.GetBestQualityInHistory(episodeId) .OrderByDescending(q => q, comparer) .FirstOrDefault()); }
public Decision IsSatisfiedBy(LocalEpisode localEpisode, DownloadClientItem downloadClientItem) { var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks; var qualityComparer = new QualityModelComparer(localEpisode.Series.QualityProfile); var languageComparer = new LanguageComparer(localEpisode.Series.LanguageProfile); var preferredWordScore = localEpisode.PreferredWordScore; foreach (var episode in localEpisode.Episodes.Where(e => e.EpisodeFileId > 0)) { var episodeFile = episode.EpisodeFile.Value; if (episodeFile == null) { _logger.Trace("Unable to get episode file details from the DB. EpisodeId: {0} EpisodeFileId: {1}", episode.Id, episode.EpisodeFileId); continue; } var qualityCompare = qualityComparer.Compare(localEpisode.Quality.Quality, episodeFile.Quality.Quality); var languageCompare = languageComparer.Compare(localEpisode.Language, episodeFile.Language); if (qualityCompare < 0) { _logger.Debug("This file isn't a quality upgrade for all episodes. Skipping {0}", localEpisode.Path); return(Decision.Reject("Not an upgrade for existing episode file(s)")); } // Same quality, is not a language upgrade, propers/repacks are preferred and it is not a revision update // This will allow language upgrades of a lower revision to be imported, which are allowed to be grabbed, // they just don't import automatically. if (qualityCompare == 0 && languageCompare <= 0 && downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && localEpisode.Quality.Revision.CompareTo(episodeFile.Quality.Revision) < 0) { _logger.Debug("This file isn't a quality revision upgrade for all episodes. Skipping {0}", localEpisode.Path); return(Decision.Reject("Not a quality revision upgrade for existing episode file(s)")); } if (languageCompare < 0 && qualityCompare == 0) { _logger.Debug("This file isn't a language upgrade for all episodes. Skipping {0}", localEpisode.Path); return(Decision.Reject("Not a language upgrade for existing episode file(s)")); } var episodeFilePreferredWordScore = _episodeFilePreferredWordCalculator.Calculate(localEpisode.Series, episodeFile); if (qualityCompare == 0 && languageCompare == 0 && preferredWordScore < episodeFilePreferredWordScore) { _logger.Debug("This file isn't a preferred word upgrade for all episodes. Skipping {0}", localEpisode.Path); return(Decision.Reject("Not a preferred word upgrade for existing episode file(s)")); } } return(Decision.Accept()); }
public Decision IsSatisfiedBy(LocalEpisode localEpisode) { var qualityComparer = new QualityModelComparer(localEpisode.Series.Profile); if (localEpisode.Episodes.Any(e => e.EpisodeFileId != 0 && qualityComparer.Compare(e.EpisodeFile.Value.Quality, localEpisode.Quality) > 0)) { _logger.Debug("This file isn't an upgrade for all episodes. Skipping {0}", localEpisode.Path); return Decision.Reject("Not an upgrade for existing episode file(s)"); } return Decision.Accept(); }
public bool IsSatisfiedBy(LocalEpisode localEpisode) { var qualityComparer = new QualityModelComparer(localEpisode.Series.QualityProfile); if (localEpisode.Episodes.Any(e => e.EpisodeFileId != 0 && qualityComparer.Compare(e.EpisodeFile.Value.Quality, localEpisode.Quality) > 0)) { _logger.Trace("This file isn't an upgrade for all episodes. Skipping {0}", localEpisode.Path); return false; } return true; }
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) { var qualityComparer = new QualityModelComparer(localMovie.Movie.Profile); if (localMovie.Movie.MovieFile != null && qualityComparer.Compare(localMovie.Movie.MovieFile.Quality, localMovie.Quality) > 0) { _logger.Debug("This file isn't an upgrade for movie. Skipping {0}", localMovie.Path); return(Decision.Reject("Not an upgrade for existing movie file")); } return(Decision.Accept()); }
public QueueModule(IBroadcastSignalRMessage broadcastSignalRMessage, IQueueService queueService, IPendingReleaseService pendingReleaseService, QualityProfileService qualityProfileService) : base(broadcastSignalRMessage) { _queueService = queueService; _pendingReleaseService = pendingReleaseService; GetResourcePaged = GetQueue; _qualityComparer = new QualityModelComparer(qualityProfileService.GetDefaultProfile(string.Empty)); }
public bool IsSatisfiedBy(LocalEpisode localEpisode) { var qualityComparer = new QualityModelComparer(localEpisode.Series.Profile); if (localEpisode.Episodes.Any(e => e.EpisodeFileId != 0 && qualityComparer.Compare(e.EpisodeFile.Value.Quality, localEpisode.Quality) > 0)) { _logger.Debug("This file isn't an upgrade for all episodes. Skipping {0}", localEpisode.Path); return(false); } return(true); }
public Decision IsSatisfiedBy(LocalEpisode localEpisode) { var qualityComparer = new QualityModelComparer(localEpisode.Series.Profile); if (localEpisode.Episodes.Any(e => e.EpisodeFileId != 0 && qualityComparer.Compare(e.EpisodeFile.Value.Quality, localEpisode.Quality) > 0)) { _logger.Debug("This file isn't an upgrade for all episodes. Skipping {0}", localEpisode.Path); return(Decision.Reject("Not an upgrade for existing episode file(s)")); } return(Decision.Accept()); }
public bool IsUpgradeAllowed(Profile qualityProfile, QualityModel currentQuality, List <CustomFormat> currentCustomFormats, QualityModel newQuality, List <CustomFormat> newCustomFormats) { var isQualityUpgrade = new QualityModelComparer(qualityProfile).Compare(newQuality, currentQuality) > 0; var isCustomFormatUpgrade = qualityProfile.CalculateCustomFormatScore(newCustomFormats) > qualityProfile.CalculateCustomFormatScore(currentCustomFormats); if ((isQualityUpgrade || isCustomFormatUpgrade) && qualityProfile.UpgradeAllowed) { _logger.Debug("Quality profile allows upgrading"); return(true); } return(false); }
private int CompareCustomFormats(DownloadDecision x, DownloadDecision y) { var left = x.RemoteMovie.ParsedMovieInfo.Quality.CustomFormats.WithNone(); var right = y.RemoteMovie.ParsedMovieInfo.Quality.CustomFormats; var leftIndicies = QualityModelComparer.GetIndicies(left, x.RemoteMovie.Movie.Profile.Value); var rightIndicies = QualityModelComparer.GetIndicies(right, y.RemoteMovie.Movie.Profile.Value); var leftTotal = leftIndicies.Sum(); var rightTotal = rightIndicies.Sum(); return(leftTotal.CompareTo(rightTotal)); }
public QueueModule(IBroadcastSignalRMessage broadcastSignalRMessage, IQueueService queueService, IPendingReleaseService pendingReleaseService, ILanguageProfileService languageProfileService, QualityProfileService qualityProfileService) : base(broadcastSignalRMessage) { _queueService = queueService; _pendingReleaseService = pendingReleaseService; GetResourcePaged = GetQueue; LANGUAGE_COMPARER = new LanguageComparer(languageProfileService.GetDefaultProfile(string.Empty)); QUALITY_COMPARER = new QualityModelComparer(qualityProfileService.GetDefaultProfile(string.Empty)); }
public bool IsUpgradable(Profile profile, QualityModel currentQuality, List <CustomFormat> currentCustomFormats, QualityModel newQuality, List <CustomFormat> newCustomFormats) { var qualityComparer = new QualityModelComparer(profile); var qualityCompare = qualityComparer.Compare(newQuality?.Quality, currentQuality.Quality); var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks; if (qualityCompare > 0) { _logger.Debug("New item has a better quality"); return(true); } if (qualityCompare < 0) { _logger.Debug("Existing item has better quality, skipping"); return(false); } var qualityRevisionCompare = newQuality?.Revision.CompareTo(currentQuality.Revision); // Accept unless the user doesn't want to prefer propers, optionally they can // use preferred words to prefer propers/repacks over non-propers/repacks. if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && qualityRevisionCompare > 0) { return(true); } var currentFormatScore = profile.CalculateCustomFormatScore(currentCustomFormats); var newFormatScore = profile.CalculateCustomFormatScore(newCustomFormats); // Reject unless the user does not prefer propers/repacks and it's a revision downgrade. if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && qualityRevisionCompare < 0) { _logger.Debug("Existing item has a better quality revision, skipping"); return(false); } if (newFormatScore <= currentFormatScore) { _logger.Debug("New item's custom formats [{0}] do not improve on [{1}], skipping", newCustomFormats.ConcatToString(), currentCustomFormats.ConcatToString()); return(false); } _logger.Debug("New item has a custom format upgrade"); return(true); }
public bool QualityCutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null) { var cutoffCompare = new QualityModelComparer(profile).Compare(currentQuality.Quality.Id, profile.Cutoff); if (cutoffCompare < 0) { return(true); } if (newQuality != null && IsRevisionUpgrade(currentQuality, newQuality)) { return(true); } return(false); }
public bool CutoffNotMet(Profile profile, QualityModel currentQuality, QualityModel newQuality = null) { var compare = new QualityModelComparer(profile).Compare(currentQuality.Quality, profile.Cutoff); if (compare < 0) { return true; } if (newQuality != null && IsRevisionUpgrade(currentQuality, newQuality)) { return true; } return false; }
private void GivenDefaultProfileWithFormats() { _customFormat1 = new CustomFormats.CustomFormat("My Format 1", "L_ENGLISH") { Id = 1 }; _customFormat2 = new CustomFormats.CustomFormat("My Format 2", "L_FRENCH") { Id = 2 }; CustomFormatsFixture.GivenCustomFormats(CustomFormats.CustomFormat.None, _customFormat1, _customFormat2); Subject = new QualityModelComparer(new Profile { Items = QualityFixture.GetDefaultQualities(), FormatItems = CustomFormatsFixture.GetSampleFormatItems() }); }
public bool CutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null) { int compare = new QualityModelComparer(profile).Compare(currentQuality.Quality, profile.Cutoff); if (compare >= 0) { if (newQuality != null && IsProperUpgrade(currentQuality, newQuality)) { return true; } _logger.Trace("Existing item meets cut-off. skipping."); return false; } return true; }
public bool CutoffNotMet(Profile profile, QualityModel currentQuality, QualityModel newQuality = null) { int compare = new QualityModelComparer(profile).Compare(currentQuality.Quality, profile.Cutoff); if (compare >= 0) { if (newQuality != null && IsRevisionUpgrade(currentQuality, newQuality)) { return(true); } _logger.Debug("Existing item meets cut-off. skipping."); return(false); } return(true); }
public bool QualityCutoffNotMet(Profile profile, QualityModel currentQuality, QualityModel newQuality = null) { var cutoff = profile.UpgradeAllowed ? profile.Cutoff : profile.FirststAllowedQuality().Id; var cutoffCompare = new QualityModelComparer(profile).Compare(currentQuality.Quality.Id, cutoff); if (cutoffCompare < 0) { return(true); } if (newQuality != null && IsRevisionUpgrade(currentQuality, newQuality)) { return(true); } return(false); }
private int CompareCustomFormats(DownloadDecision x, DownloadDecision y) { var left = x.RemoteMovie.ParsedMovieInfo.Quality.CustomFormats.ToArray().ToList(); if (left.Count == 0) { left.Add(CustomFormat.None); } var right = y.RemoteMovie.ParsedMovieInfo.Quality.CustomFormats; var leftIndicies = QualityModelComparer.GetIndicies(left, x.RemoteMovie.Movie.Profile.Value); var rightIndicies = QualityModelComparer.GetIndicies(right, y.RemoteMovie.Movie.Profile.Value); var leftTotal = leftIndicies.Sum(); var rightTotal = rightIndicies.Sum(); return(leftTotal.CompareTo(rightTotal)); }
public bool IsUpgradable(Profile profile, QualityModel currentQuality, QualityModel newQuality = null) { if (newQuality != null) { int compare = new QualityModelComparer(profile).Compare(newQuality, currentQuality); if (compare <= 0) { return(false); } if (IsRevisionUpgrade(currentQuality, newQuality)) { return(true); } } return(true); }
public bool IsUpgradable(Profile profile, QualityModel currentQuality, QualityModel newQuality = null) { if (newQuality != null) { int compare = new QualityModelComparer(profile).Compare(newQuality, currentQuality); if (compare <= 0) { return false; } if (IsRevisionUpgrade(currentQuality, newQuality)) { return true; } } return true; }
public QueueController(IBroadcastSignalRMessage broadcastSignalRMessage, IQueueService queueService, IPendingReleaseService pendingReleaseService, QualityProfileService qualityProfileService, ITrackedDownloadService trackedDownloadService, IFailedDownloadService failedDownloadService, IIgnoredDownloadService ignoredDownloadService, IProvideDownloadClient downloadClientProvider) : base(broadcastSignalRMessage) { _queueService = queueService; _pendingReleaseService = pendingReleaseService; _trackedDownloadService = trackedDownloadService; _failedDownloadService = failedDownloadService; _ignoredDownloadService = ignoredDownloadService; _downloadClientProvider = downloadClientProvider; _qualityComparer = new QualityModelComparer(qualityProfileService.GetDefaultProfile(string.Empty)); }
private void GivenGroupedProfile() { var profile = new QualityProfile { Items = new List <QualityProfileQualityItem> { new QualityProfileQualityItem { Allowed = false, Quality = Quality.SDTV }, new QualityProfileQualityItem { Allowed = false, Quality = Quality.DVD }, new QualityProfileQualityItem { Allowed = true, Items = new List <QualityProfileQualityItem> { new QualityProfileQualityItem { Allowed = true, Quality = Quality.HDTV720p }, new QualityProfileQualityItem { Allowed = true, Quality = Quality.WEBDL720p } } }, new QualityProfileQualityItem { Allowed = true, Quality = Quality.Bluray720p } } }; Subject = new QualityModelComparer(profile); }
public bool IsUpgradable(Profile profile, QualityModel currentQuality, QualityModel newQuality = null) { if (newQuality != null) { int compare = new QualityModelComparer(profile).Compare(newQuality, currentQuality); if (compare <= 0) { _logger.Debug("existing item has better or equal quality. skipping"); return(false); } if (IsRevisionUpgrade(currentQuality, newQuality)) { return(true); } } return(true); }
public bool IsUpgradable(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null) { if (newQuality != null) { int compare = new QualityModelComparer(profile).Compare(newQuality, currentQuality); if (compare <= 0) { _logger.Trace("existing item has better or equal quality. skipping"); return false; } if (IsProperUpgrade(currentQuality, newQuality)) { return true; } } return true; }
public Decision IsSatisfiedBy(LocalEpisode localEpisode, DownloadClientItem downloadClientItem) { var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks; var qualityComparer = new QualityModelComparer(localEpisode.Series.QualityProfile); var languageComparer = new LanguageComparer(localEpisode.Series.LanguageProfile); foreach (var episode in localEpisode.Episodes.Where(e => e.EpisodeFileId > 0)) { var episodeFile = episode.EpisodeFile.Value; if (episodeFile == null) { _logger.Trace("Unable to get episode file details from the DB. EpisodeId: {0} EpisodeFileId: {1}", episode.Id, episode.EpisodeFileId); continue; } var qualityCompare = qualityComparer.Compare(localEpisode.Quality.Quality, episodeFile.Quality.Quality); if (qualityCompare < 0) { _logger.Debug("This file isn't a quality upgrade for all episodes. Skipping {0}", localEpisode.Path); return(Decision.Reject("Not an upgrade for existing episode file(s)")); } if (qualityCompare == 0 && downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && localEpisode.Quality.Revision.CompareTo(episodeFile.Quality.Revision) < 0) { _logger.Debug("This file isn't a quality upgrade for all episodes. Skipping {0}", localEpisode.Path); return(Decision.Reject("Not an upgrade for existing episode file(s)")); } if (languageComparer.Compare(localEpisode.Language, episodeFile.Language) < 0 && qualityCompare == 0) { _logger.Debug("This file isn't a language upgrade for all episodes. Skipping {0}", localEpisode.Path); return(Decision.Reject("Not an upgrade for existing episode file(s)")); } } return(Decision.Accept()); }
private void GivenCustomQualityProfile() { Subject = new QualityModelComparer(new QualityProfile { Items = QualityFixture.GetDefaultQualities(Quality.Bluray720p, Quality.DVD) }); }
public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { //How do we want to handle drone being off and the automatic search being triggered? //TODO: Add a flag to the search to state it is a "scheduled" search if (searchCriteria != null) { _logger.Debug("Ignore delay for searches"); return Decision.Accept(); } var profile = subject.Series.Profile.Value; var delayProfile = _delayProfileService.BestForTags(subject.Series.Tags); var delay = delayProfile.GetProtocolDelay(subject.Release.DownloadProtocol); var isPreferredProtocol = subject.Release.DownloadProtocol == delayProfile.PreferredProtocol; if (delay == 0) { _logger.Debug("Profile does not require a waiting period before download for {0}.", subject.Release.DownloadProtocol); return Decision.Accept(); } var comparer = new QualityModelComparer(profile); if (isPreferredProtocol) { foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) { var upgradable = _qualityUpgradableSpecification.IsUpgradable(profile, file.Quality, subject.ParsedEpisodeInfo.Quality); if (upgradable) { var revisionUpgrade = _qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality); if (revisionUpgrade) { _logger.Debug("New quality is a better revision for existing quality, skipping delay"); return Decision.Accept(); } } } } //If quality meets or exceeds the best allowed quality in the profile accept it immediately var bestQualityInProfile = new QualityModel(profile.LastAllowedQuality()); var isBestInProfile = comparer.Compare(subject.ParsedEpisodeInfo.Quality, bestQualityInProfile) >= 0; if (isBestInProfile && isPreferredProtocol) { _logger.Debug("Quality is highest in profile for preferred protocol, will not delay"); return Decision.Accept(); } var episodeIds = subject.Episodes.Select(e => e.Id); var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds); if (oldest != null && oldest.Release.AgeMinutes > delay) { return Decision.Accept(); } if (subject.Release.AgeMinutes < delay) { _logger.Debug("Waiting for better quality release, There is a {0} minute delay on {1}", delay, subject.Release.DownloadProtocol); return Decision.Reject("Waiting for better quality release"); } return Decision.Accept(); }
private void GivenDefaultQualityProfile() { Subject = new QualityModelComparer(new QualityProfile { Items = QualityFixture.GetDefaultQualities() }); }