コード例 #1
0
        public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            if (searchCriteria != null)
            {
                return(Decision.Accept());
            }

            var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks;

            if (downloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer)
            {
                _logger.Debug("Propers are not preferred, skipping check");
                return(Decision.Accept());
            }

            foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
            {
                if (_upgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality))
                {
                    if (downloadPropersAndRepacks == ProperDownloadTypes.DoNotUpgrade)
                    {
                        _logger.Debug("Auto downloading of propers is disabled");
                        return(Decision.Reject("Proper downloading is disabled"));
                    }

                    if (file.DateAdded < DateTime.Today.AddDays(-7))
                    {
                        _logger.Debug("Proper for old file, rejecting: {0}", subject);
                        return(Decision.Reject("Proper for old file"));
                    }
                }
            }

            return(Decision.Accept());
        }
コード例 #2
0
        public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria)
        {
            if (searchCriteria != null)
            {
                return(Decision.Accept());
            }

            var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks;

            if (downloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer)
            {
                _logger.Debug("Propers are not preferred, skipping check");
                return(Decision.Accept());
            }

            foreach (var album in subject.Albums)
            {
                var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id);

                foreach (var file in trackFiles)
                {
                    if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedAlbumInfo.Quality))
                    {
                        if (downloadPropersAndRepacks == ProperDownloadTypes.DoNotUpgrade)
                        {
                            _logger.Debug("Auto downloading of propers is disabled");
                            return(Decision.Reject("Proper downloading is disabled"));
                        }

                        if (file.DateAdded < DateTime.Today.AddDays(-7))
                        {
                            _logger.Debug("Proper for old file, rejecting: {0}", subject);
                            return(Decision.Reject("Proper for old file"));
                        }
                    }
                }
            }

            return(Decision.Accept());
        }