Ejemplo n.º 1
0
        public override HealthCheck Check()
        {
            var enabled       = _indexerFactory.GetAvailableProviders();
            var rssEnabled    = _indexerFactory.RssEnabled();
            var searchEnabled = _indexerFactory.SearchEnabled();

            if (enabled.Empty())
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Error, "No indexers are enabled"));
            }

            if (enabled.All(i => i.SupportsRss == false))
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not support RSS sync"));
            }

            if (enabled.All(i => i.SupportsSearch == false))
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not support searching"));
            }

            if (rssEnabled.Empty())
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not have RSS sync enabled"));
            }

            if (searchEnabled.Empty())
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not have searching enabled"));
            }

            return(new HealthCheck(GetType()));
        }
Ejemplo n.º 2
0
        public override HealthCheck Check()
        {
            var enabled = _indexerFactory.GetAvailableProviders();

            if (!enabled.Any())
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Error, "No indexers are enabled"));
            }

            if (enabled.All(i => i.SupportsSearching == false))
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not support searching"));
            }

            return(new HealthCheck(GetType()));
        }
Ejemplo n.º 3
0
        public override HealthCheck Check()
        {
            var indexers = _indexerFactory.GetAvailableProviders();

            foreach (var indexer in indexers)
            {
                var definition = (IndexerDefinition)indexer.Definition;

                if (definition.Settings is GazelleSettings s &&
                    s.BaseUrl == "https://redacted.ch")
                {
                    return(new HealthCheck(GetType(), HealthCheckResult.Warning, "You have set up Redacted as a Gazelle indexer, please reconfigure using the Redacted indexer setting"));
                }
            }

            return(new HealthCheck(GetType()));
        }
Ejemplo n.º 4
0
        public override HealthCheck Check()
        {
            var enabledProviders = _providerFactory.GetAvailableProviders();
            var backOffProviders = enabledProviders.Join(_providerStatusService.GetBlockedProviders(),
                                                         i => i.Definition.Id,
                                                         s => s.ProviderId,
                                                         (i, s) => new { Indexer = i, Status = s })
                                   .ToList();

            if (backOffProviders.Empty())
            {
                return(new HealthCheck(GetType()));
            }

            if (backOffProviders.Count == enabledProviders.Count)
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Error, "All indexers are unavailable due to failures", "#indexers-are-unavailable-due-to-failures"));
            }

            return(new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format("Indexers unavailable due to failures: {0}", string.Join(", ", backOffProviders.Select(v => v.Indexer.Definition.Name))), "#indexers-are-unavailable-due-to-failures"));
        }
Ejemplo n.º 5
0
        public List <ReleaseInfo> Fetch()
        {
            var result = new List <ReleaseInfo>();

            var indexers = _indexerFactory.GetAvailableProviders().ToList();

            if (!indexers.Any())
            {
                _logger.Warn("No available indexers. check your configuration.");
                return(result);
            }

            _logger.Debug("Available indexers {0}", indexers.Count);

            var taskList    = new List <Task>();
            var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None);

            foreach (var indexer in indexers)
            {
                var indexerLocal = indexer;

                var task = taskFactory.StartNew(() =>
                {
                    var indexerFeed = _feedFetcher.FetchRss(indexerLocal);

                    lock (result)
                    {
                        result.AddRange(indexerFeed);
                    }
                }).LogExceptions();

                taskList.Add(task);
            }

            Task.WaitAll(taskList.ToArray());

            _logger.Debug("Found {0} reports", result.Count);

            return(result);
        }
Ejemplo n.º 6
0
        private List <DownloadDecision> Dispatch(Func <IIndexer, IEnumerable <ReleaseInfo> > searchAction, SearchCriteriaBase criteriaBase)
        {
            var indexers = _indexerFactory.GetAvailableProviders().ToList();
            var reports  = new List <ReleaseInfo>();

            _logger.ProgressInfo("Searching {0} indexers for {1}", indexers.Count, criteriaBase);

            var taskList    = new List <Task>();
            var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None);

            foreach (var indexer in indexers)
            {
                var indexerLocal = indexer;

                taskList.Add(taskFactory.StartNew(() =>
                {
                    try
                    {
                        var indexerReports = searchAction(indexerLocal);

                        lock (reports)
                        {
                            reports.AddRange(indexerReports);
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.ErrorException("Error while searching for " + criteriaBase, e);
                    }
                }).LogExceptions());
            }

            Task.WaitAll(taskList.ToArray());

            _logger.Debug("Total of {0} reports were found for {1} from {2} indexers", reports.Count, criteriaBase, indexers.Count);

            return(_makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList());
        }
Ejemplo n.º 7
0
        public override HealthCheck Check()
        {
            var enabledProviders = _providerFactory.GetAvailableProviders();
            var backOffProviders = enabledProviders.Join(_providerStatusService.GetBlockedProviders(),
                                                         i => i.Definition.Id,
                                                         s => s.ProviderId,
                                                         (i, s) => new { Provider = i, Status = s })
                                   .Where(p => p.Status.InitialFailure.HasValue &&
                                          p.Status.InitialFailure.Value.After(
                                              DateTime.UtcNow.AddHours(-6)))
                                   .ToList();

            if (backOffProviders.Empty())
            {
                return(new HealthCheck(GetType()));
            }

            if (backOffProviders.Count == enabledProviders.Count)
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Error, "All indexers are unavailable due to failures", "#indexers_are_unavailable_due_to_failures"));
            }

            return(new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format("Indexers unavailable due to failures: {0}", string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))), "#indexers_are_unavailable_due_to_failures"));
        }