Example #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()));
        }
Example #2
0
        public override HealthCheck Check()
        {
            var enabled = _indexerFactory.SearchEnabled(false);

            if (enabled.Empty())
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Warning, "No indexers available with Search enabled, Sonarr will not provide any search results"));
            }

            var active = _indexerFactory.SearchEnabled(true);

            if (active.Empty())
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Warning, "All search-capable indexers are temporarily unavailable due to recent indexer errors"));
            }

            return(new HealthCheck(GetType()));
        }
Example #3
0
        private List <DownloadDecision> Dispatch(Func <IIndexer, IEnumerable <ReleaseInfo> > searchAction, SearchCriteriaBase criteriaBase)
        {
            var indexers = _indexerFactory.SearchEnabled();
            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.Error(e, "Error while searching for {0}", criteriaBase);
                    }
                }).LogExceptions());
            }

            Task.WaitAll(taskList.ToArray());

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

            // Update the last search time for all episodes if at least 1 indexer was searched.
            if (indexers.Any())
            {
                var lastSearchTime = DateTime.UtcNow;
                _logger.Debug("Setting last search time to: {0}", lastSearchTime);

                criteriaBase.Episodes.ForEach(e => e.LastSearchTime = lastSearchTime);
                _episodeService.UpdateEpisodes(criteriaBase.Episodes);
            }

            return(_makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList());
        }
Example #4
0
        private List <DownloadDecision> Dispatch(Func <IIndexer, IEnumerable <ReleaseInfo> > searchAction, SearchCriteriaBase criteriaBase)
        {
            var indexers = _indexerFactory.SearchEnabled().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());
        }