public void Setup()
        {
            var qualityProfile = new NzbDrone.Core.Qualities.QualityProfile
                {
                    Name = "Test",
                    Cutoff = Quality.WEBDL720p,
                    Items = NzbDrone.Core.Test.Qualities.QualityFixture.GetDefaultQualities()
                };

            
            qualityProfile = Db.Insert(qualityProfile);

            var series = Builder<Series>.CreateListOfSize(1)
                .All()
                .With(v => v.QualityProfileId = qualityProfile.Id)
                .BuildListOfNew();

            Db.InsertMany(series);

            var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(1)
                .All()
                .With(v => v.SeriesId = series[0].Id)
                .BuildListOfNew();

            Db.InsertMany(episodeFiles);

            var episodes = Builder<Episode>.CreateListOfSize(10)
                .All()
                .With(v => v.Monitored = true)
                .With(v => v.EpisodeFileId = episodeFiles[0].Id)
                .With(v => v.SeriesId = series[0].Id)
                .BuildListOfNew();

            Db.InsertMany(episodes);
        }
        public QualityModelComparer(QualityProfile profile)
        {
            Ensure.That(profile, () => profile).IsNotNull();
            Ensure.That(profile.Items, () => profile.Items).HasItems();

            _profile = profile;
        }
Exemple #3
0
        public void Setup()
        {
            var qualityProfile = new NzbDrone.Core.Qualities.QualityProfile
            {
                Name   = "Test",
                Cutoff = Quality.WEBDL720p,
                Items  = NzbDrone.Core.Test.Qualities.QualityFixture.GetDefaultQualities()
            };


            qualityProfile = Db.Insert(qualityProfile);

            var series = Builder <Series> .CreateListOfSize(1)
                         .All()
                         .With(v => v.QualityProfileId = qualityProfile.Id)
                         .BuildListOfNew();

            Db.InsertMany(series);

            var episodeFiles = Builder <EpisodeFile> .CreateListOfSize(1)
                               .All()
                               .With(v => v.SeriesId = series[0].Id)
                               .BuildListOfNew();

            Db.InsertMany(episodeFiles);

            var episodes = Builder <Episode> .CreateListOfSize(10)
                           .All()
                           .With(v => v.Monitored     = true)
                           .With(v => v.EpisodeFileId = episodeFiles[0].Id)
                           .With(v => v.SeriesId      = series[0].Id)
                           .BuildListOfNew();

            Db.InsertMany(episodes);
        }
        public bool CutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null)
        {
            if (currentQuality.Quality >= profile.Cutoff)
            {
                if (newQuality != null && IsProperUpgrade(currentQuality, newQuality))
                {
                    return true;
                }

                _logger.Trace("Existing item meets cut-off. skipping.");
                return false;
            }

            return true;
        }
        private QualityProfile AddDefaultQualityProfile(string name, Quality cutoff, params Quality[] allowed)
        {
            var items = Quality.DefaultQualityDefinitions
                        .OrderBy(v => v.Weight)
                        .Select(v => new QualityProfileItem {
                Quality = v.Quality, Allowed = allowed.Contains(v.Quality)
            })
                        .ToList();

            var qualityProfile = new QualityProfile {
                Name = name, Cutoff = cutoff, Items = items
            };

            return(Add(qualityProfile));
        }
        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.Debug("Existing item meets cut-off. skipping.");
                return false;
            }

            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;
        }
Exemple #8
0
        public void Handle(ApplicationStartedEvent message)
        {
            if (All().Any())
            {
                return;
            }

            _logger.Info("Setting up default quality profiles");

            var sd = new QualityProfile
            {
                Name    = "SD",
                Allowed = new List <Quality>
                {
                    Quality.SDTV,
                    Quality.WEBDL480p,
                    Quality.DVD
                },
                Cutoff = Quality.SDTV
            };

            var hd720p = new QualityProfile
            {
                Name    = "HD 720p",
                Allowed = new List <Quality>
                {
                    Quality.HDTV720p,
                    Quality.WEBDL720p,
                    Quality.Bluray720p
                },
                Cutoff = Quality.HDTV720p
            };


            var hd1080p = new QualityProfile
            {
                Name    = "HD 1080p",
                Allowed = new List <Quality>
                {
                    Quality.HDTV1080p,
                    Quality.WEBDL1080p,
                    Quality.Bluray1080p
                },
                Cutoff = Quality.HDTV1080p
            };

            var hdAll = new QualityProfile
            {
                Name    = "HD - All",
                Allowed = new List <Quality>
                {
                    Quality.HDTV720p,
                    Quality.WEBDL720p,
                    Quality.Bluray720p,
                    Quality.HDTV1080p,
                    Quality.WEBDL1080p,
                    Quality.Bluray1080p
                },
                Cutoff = Quality.HDTV720p
            };

            Add(sd);
            Add(hd720p);
            Add(hd1080p);
            Add(hdAll);
        }
Exemple #9
0
 public void Update(QualityProfile profile)
 {
     _qualityProfileRepository.Update(profile);
 }
Exemple #10
0
 public QualityProfile Add(QualityProfile profile)
 {
     return(_qualityProfileRepository.Insert(profile));
 }