當前位置: 首頁>>代碼示例>>C#>>正文


C# Definitions.SearchCriteriaBase類代碼示例

本文整理匯總了C#中NzbDrone.Core.IndexerSearch.Definitions.SearchCriteriaBase的典型用法代碼示例。如果您正苦於以下問題:C# SearchCriteriaBase類的具體用法?C# SearchCriteriaBase怎麽用?C# SearchCriteriaBase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SearchCriteriaBase類屬於NzbDrone.Core.IndexerSearch.Definitions命名空間,在下文中一共展示了SearchCriteriaBase類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsSatisfiedBy

        public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            _logger.Debug("Checking if release contains any restricted terms: {0}", subject);

            var restrictionsString = _configService.ReleaseRestrictions;

            if (String.IsNullOrWhiteSpace(restrictionsString))
            {
                _logger.Debug("No restrictions configured, allowing: {0}", subject);
                return true;
            }

            var restrictions = restrictionsString.Split(new []{ '\n' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var restriction in restrictions)
            {
                if (subject.Release.Title.ToLowerInvariant().Contains(restriction.ToLowerInvariant()))
                {
                    _logger.Debug("{0} is restricted: {1}", subject, restriction);
                    return false;
                }
            }

            _logger.Debug("No restrictions apply, allowing: {0}", subject);
            return true;
        }
開發者ID:BO45,項目名稱:NzbDrone,代碼行數:26,代碼來源:NotRestrictedReleaseSpecification.cs

示例2: GetDecisionForReport

        private DownloadDecision GetDecisionForReport(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria = null)
        {
            var reasons = _specifications.Select(c => EvaluateSpec(c, remoteEpisode, searchCriteria))
                                         .Where(c => c != null);

            return new DownloadDecision(remoteEpisode, reasons.ToArray());
        }
開發者ID:pra85,項目名稱:Sonarr,代碼行數:7,代碼來源:DownloadDecisionMaker.cs

示例3: IsSatisfiedBy

        public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            if (searchCriteria != null)
            {
                return true;
            }

            foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
            {
                if (_qualityUpgradableSpecification.IsProperUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality))
                {
                    if (file.DateAdded < DateTime.Today.AddDays(-7))
                    {
                        _logger.Trace("Proper for old file, rejecting: {0}", subject);
                        return false;
                    }

                    if (!_configService.AutoDownloadPropers)
                    {
                        _logger.Trace("Auto downloading of propers is disabled");
                        return false;
                    }
                }
            }

            return true;
        }
開發者ID:BubbaFatAss,項目名稱:NzbDrone,代碼行數:27,代碼來源:ProperSpecification.cs

示例4: GetEpisodes

        public List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool sceneSource, SearchCriteriaBase searchCriteria = null)
        {
            if (parsedEpisodeInfo.FullSeason)
            {
                return _episodeService.GetEpisodesBySeason(series.Id, parsedEpisodeInfo.SeasonNumber);
            }

            if (parsedEpisodeInfo.IsDaily)
            {
                if (series.SeriesType == SeriesTypes.Standard)
                {
                    _logger.Warn("Found daily-style episode for non-daily series: {0}.", series);
                    return new List<Episode>();
                }

                var episodeInfo = GetDailyEpisode(series, parsedEpisodeInfo.AirDate, searchCriteria);

                if (episodeInfo != null)
                {
                    return new List<Episode> { episodeInfo };
                }

                return new List<Episode>();
            }

            if (parsedEpisodeInfo.IsAbsoluteNumbering)
            {
                return GetAnimeEpisodes(series, parsedEpisodeInfo, sceneSource);
            }

            return GetStandardEpisodes(series, parsedEpisodeInfo, sceneSource, searchCriteria);
        }
開發者ID:mike-tesch,項目名稱:Sonarr,代碼行數:32,代碼來源:ParsingService.cs

示例5: IsSatisfiedBy

        public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            var releaseGroup = subject.ParsedEpisodeInfo.ReleaseGroup;

            if (subject.Series.SeriesType != SeriesTypes.Anime)
            {
                return Decision.Accept();
            }

            foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
            {
                if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality))
                {
                    if (file.ReleaseGroup.IsNullOrWhiteSpace())
                    {
                        _logger.Debug("Unable to compare release group, existing file's release group is unknown");
                        return Decision.Reject("Existing release group is unknown");
                    }

                    if (releaseGroup.IsNullOrWhiteSpace())
                    {
                        _logger.Debug("Unable to compare release group, release's release group is unknown");
                        return Decision.Reject("Release group is unknown");
                    }

                    if (file.ReleaseGroup != releaseGroup)
                    {
                        _logger.Debug("Existing Release group is: {0} - release's release group is: {1}", file.ReleaseGroup, releaseGroup);
                        return Decision.Reject("{0} does not match existing release group {1}", releaseGroup, file.ReleaseGroup);
                    }
                }
            }

            return Decision.Accept();
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:35,代碼來源:AnimeVersionUpgradeSpecification.cs

示例6: IsSatisfiedBy

        public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
        {
            if (searchCriteria == null)
            {
                return Decision.Accept();
            }

            var singleEpisodeSpec = searchCriteria as SingleEpisodeSearchCriteria;
            if (singleEpisodeSpec == null) return Decision.Accept();

            if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)
            {
                _logger.Debug("Season number does not match searched season number, skipping.");
                return Decision.Reject("Wrong season");
            }

            if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Any())
            {
                _logger.Debug("Full season result during single episode search, skipping.");
                return Decision.Reject("Full season pack");
            }

            if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber))
            {
                _logger.Debug("Episode number does not match searched episode number, skipping.");
                return Decision.Reject("Wrong episode");
            }

            return Decision.Accept();
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:30,代碼來源:SingleEpisodeSearchMatchSpecification.cs

示例7: IsSatisfiedBy

        public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            if (searchCriteria != null)
            {
                if (!searchCriteria.MonitoredEpisodesOnly)
                {
                    _logger.Debug("Skipping monitored check during search");
                    return Decision.Accept();
                }
            }

            if (!subject.Series.Monitored)
            {
                _logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series);
                return Decision.Reject("Series is not monitored");
            }

            var monitoredCount = subject.Episodes.Count(episode => episode.Monitored);
            if (monitoredCount == subject.Episodes.Count)
            {
                return Decision.Accept();
            }

            _logger.Debug("Only {0}/{1} episodes are monitored. skipping.", monitoredCount, subject.Episodes.Count);
            return Decision.Reject("Episode is not monitored");
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:26,代碼來源:MonitoredEpisodeSpecification.cs

示例8: EvaluateSpec

        private string EvaluateSpec(IRejectWithReason spec, RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase = null)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(spec.RejectionReason))
                {
                    throw new InvalidOperationException("[Need Rejection Text]");
                }

                var generalSpecification = spec as IDecisionEngineSpecification;
                if (generalSpecification != null && !generalSpecification.IsSatisfiedBy(remoteEpisode, searchCriteriaBase))
                {
                    return spec.RejectionReason;
                }
            }
            catch (Exception e)
            {
                e.Data.Add("report", remoteEpisode.Release.ToJson());
                e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson());
                _logger.ErrorException("Couldn't evaluate decision on " + remoteEpisode.Release.Title, e);
                return string.Format("{0}: {1}", spec.GetType().Name, e.Message);
            }

            return null;
        }
開發者ID:BO45,項目名稱:NzbDrone,代碼行數:25,代碼來源:DownloadDecisionMaker.cs

示例9: IsSatisfiedBy

        public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            if (subject.Release.DownloadProtocol != Indexers.DownloadProtocol.Usenet)
            {
                _logger.Debug("Not checking minimum age requirement for non-usenet report");
                return Decision.Accept();
            }

            var age = subject.Release.AgeMinutes;
            var minimumAge = _configService.MinimumAge;

            if (minimumAge == 0)
            {
                _logger.Debug("Minimum age is not set.");
                return Decision.Accept();
            }


            _logger.Debug("Checking if report meets minimum age requirements. {0}", age);

            if (age < minimumAge)
            {
                _logger.Debug("Only {0} minutes old, minimum age is {1} minutes", age, minimumAge);
                return Decision.Reject("Only {0} minutes old, minimum age is {1} minutes", age, minimumAge);
            }

            _logger.Debug("Release is {0} minutes old, greater than minimum age of {1} minutes", age, minimumAge);

            return Decision.Accept();
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:30,代碼來源:MinimumAgeSpecification.cs

示例10: IsSatisfiedBy

        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();
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:27,代碼來源:QueueSpecification.cs

示例11: IsSatisfiedBy

        public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            _logger.Debug("Checking if release meets restrictions: {0}", subject);

            var title = subject.Release.Title;
            var restrictions = _restrictionService.AllForTags(subject.Series.Tags);

            var required = restrictions.Where(r => r.Required.IsNotNullOrWhiteSpace());
            var ignored = restrictions.Where(r => r.Ignored.IsNotNullOrWhiteSpace());

            foreach (var r in required)
            {
                var split = r.Required.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();

                if (!ContainsAny(split, title))
                {
                    _logger.Debug("[{0}] does not contain one of the required terms: {1}", title, r.Required);
                    return Decision.Reject("Does not contain one of the required terms: {0}", r.Required.Replace(",", ", "));
                }
            }

            foreach (var r in ignored)
            {
                var split = r.Ignored.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

                if (ContainsAny(split, title))
                {
                    _logger.Debug("[{0}] contains one or more ignored terms: {1}", title, r.Ignored);
                    return Decision.Reject("Contains one or more ignored terms: {0}", r.Ignored.Replace(",", ", "));
                }
            }

            _logger.Debug("[{0}] No restrictions apply, allowing", subject);
            return Decision.Accept();
        }
開發者ID:keep3r,項目名稱:Sonarr,代碼行數:35,代碼來源:ReleaseRestrictionsSpecification.cs

示例12: IsSatisfiedBy

        public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            _logger.Debug("Beginning size check for: {0}", subject);

            var quality = subject.ParsedEpisodeInfo.Quality.Quality;

            if (quality == Quality.RAWHD)
            {
                _logger.Debug("Raw-HD release found, skipping size check.");
                return true;
            }

            if (quality == Quality.Unknown)
            {
                _logger.Debug("Unknown quality. skipping size check.");
                return false;
            }

            var qualityDefinition = _qualityDefinitionService.Get(quality);
            var minSize = qualityDefinition.MinSize.Megabytes();

            //Multiply maxSize by Series.Runtime
            minSize = minSize * subject.Series.Runtime * subject.Episodes.Count;

            //If the parsed size is smaller than minSize we don't want it
            if (subject.Release.Size < minSize)
            {
                _logger.Debug("Item: {0}, Size: {1} is smaller than minimum allowed size ({2}), rejecting.", subject, subject.Release.Size, minSize);
                return false;
            }
            if (qualityDefinition.MaxSize == 0)
            {
                _logger.Debug("Max size is 0 (unlimited) - skipping check.");
            }
            else
            {
                var maxSize = qualityDefinition.MaxSize.Megabytes();

                //Multiply maxSize by Series.Runtime
                maxSize = maxSize * subject.Series.Runtime * subject.Episodes.Count;

                //Check if there was only one episode parsed and it is the first
                if (subject.Episodes.Count == 1 && _episodeService.IsFirstOrLastEpisodeOfSeason(subject.Episodes.First().Id))
                {
                    maxSize = maxSize * 2;
                }

                //If the parsed size is greater than maxSize we don't want it
                if (subject.Release.Size > maxSize)
                {
                    _logger.Debug("Item: {0}, Size: {1} is greater than maximum allowed size ({2}), rejecting.", subject, subject.Release.Size, maxSize);
                    return false;
                }
            }
            _logger.Debug("Item: {0}, meets size constraints.", subject);
            return true;
        }
開發者ID:Taloth,項目名稱:NzbDrone,代碼行數:57,代碼來源:AcceptableSizeSpecification.cs

示例13: IsSatisfiedBy

        public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 70.Megabytes())
            {
                return false;
            }

            return true;
        }
開發者ID:peterlandry,項目名稱:NzbDrone,代碼行數:9,代碼來源:NotSampleSpecification.cs

示例14: IsSatisfiedBy

        public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {          
            if (_blacklistService.Blacklisted(subject.Series.Id, subject.Release))
            {
                _logger.Debug("{0} is blacklisted, rejecting.", subject.Release.Title);
                return Decision.Reject("Release is blacklisted");
            }

            return Decision.Accept();
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:10,代碼來源:BlacklistSpecification.cs

示例15: IsSatisfiedBy

        public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 70.Megabytes())
            {
                _logger.Debug("Sample release, rejecting.");
                return Decision.Reject("Sample");
            }

            return Decision.Accept();
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:10,代碼來源:NotSampleSpecification.cs


注:本文中的NzbDrone.Core.IndexerSearch.Definitions.SearchCriteriaBase類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。