diff --git a/src/NzbDrone.Core/Applications/ApplicationBase.cs b/src/NzbDrone.Core/Applications/ApplicationBase.cs index e055d37aa..b4d32f054 100644 --- a/src/NzbDrone.Core/Applications/ApplicationBase.cs +++ b/src/NzbDrone.Core/Applications/ApplicationBase.cs @@ -11,6 +11,8 @@ namespace NzbDrone.Core.Applications public abstract class ApplicationBase : IApplication where TSettings : IProviderConfig, new() { + private readonly IIndexerFactory _indexerFactory; + protected readonly IAppIndexerMapService _appIndexerMapService; protected readonly Logger _logger; @@ -27,9 +29,10 @@ namespace NzbDrone.Core.Applications protected TSettings Settings => (TSettings)Definition.Settings; - public ApplicationBase(IAppIndexerMapService appIndexerMapService, Logger logger) + public ApplicationBase(IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger) { _appIndexerMapService = appIndexerMapService; + _indexerFactory = indexerFactory; _logger = logger; } @@ -62,5 +65,17 @@ namespace NzbDrone.Core.Applications { return null; } + + protected IndexerCapabilities GetIndexerCapabilities(IndexerDefinition indexer) + { + try + { + return _indexerFactory.GetInstance(indexer).GetCapabilities(); + } + catch (Exception) + { + return indexer.Capabilities; + } + } } } diff --git a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs index fcf2f0824..24837c3ec 100644 --- a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs +++ b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs @@ -15,14 +15,12 @@ namespace NzbDrone.Core.Applications.LazyLibrarian private readonly ILazyLibrarianV1Proxy _lazyLibrarianV1Proxy; private readonly IConfigFileProvider _configFileProvider; - private readonly IIndexerFactory _indexerFactory; public LazyLibrarian(ILazyLibrarianV1Proxy lazyLibrarianV1Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger) - : base(appIndexerMapService, logger) + : base(appIndexerMapService, indexerFactory, logger) { _lazyLibrarianV1Proxy = lazyLibrarianV1Proxy; _configFileProvider = configFileProvider; - _indexerFactory = indexerFactory; } public override ValidationResult Test() @@ -67,7 +65,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian public override void AddIndexer(IndexerDefinition indexer) { - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty()) { @@ -111,7 +109,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); var indexerProps = indexerMapping.RemoteIndexerName.Split(","); diff --git a/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs b/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs index 80ae02319..14d6824a4 100644 --- a/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs +++ b/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs @@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Lidarr private readonly ILidarrV1Proxy _lidarrV1Proxy; private readonly ICached> _schemaCache; private readonly IConfigFileProvider _configFileProvider; - private readonly IIndexerFactory _indexerFactory; public Lidarr(ICacheManager cacheManager, ILidarrV1Proxy lidarrV1Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger) - : base(appIndexerMapService, logger) + : base(appIndexerMapService, indexerFactory, logger) { _schemaCache = cacheManager.GetCache>(GetType()); _lidarrV1Proxy = lidarrV1Proxy; _configFileProvider = configFileProvider; - _indexerFactory = indexerFactory; } public override ValidationResult Test() @@ -120,7 +118,7 @@ namespace NzbDrone.Core.Applications.Lidarr public override void AddIndexer(IndexerDefinition indexer) { - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty()) { @@ -163,7 +161,7 @@ namespace NzbDrone.Core.Applications.Lidarr { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); diff --git a/src/NzbDrone.Core/Applications/Mylar/Mylar.cs b/src/NzbDrone.Core/Applications/Mylar/Mylar.cs index 3724aaf1c..e9fd9ffe7 100644 --- a/src/NzbDrone.Core/Applications/Mylar/Mylar.cs +++ b/src/NzbDrone.Core/Applications/Mylar/Mylar.cs @@ -15,14 +15,12 @@ namespace NzbDrone.Core.Applications.Mylar private readonly IMylarV3Proxy _mylarV3Proxy; private readonly IConfigFileProvider _configFileProvider; - private readonly IIndexerFactory _indexerFactory; public Mylar(IMylarV3Proxy mylarV3Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger) - : base(appIndexerMapService, logger) + : base(appIndexerMapService, indexerFactory, logger) { _mylarV3Proxy = mylarV3Proxy; _configFileProvider = configFileProvider; - _indexerFactory = indexerFactory; } public override ValidationResult Test() @@ -67,7 +65,7 @@ namespace NzbDrone.Core.Applications.Mylar public override void AddIndexer(IndexerDefinition indexer) { - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty()) { @@ -111,7 +109,7 @@ namespace NzbDrone.Core.Applications.Mylar { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); var indexerProps = indexerMapping.RemoteIndexerName.Split(","); diff --git a/src/NzbDrone.Core/Applications/Radarr/Radarr.cs b/src/NzbDrone.Core/Applications/Radarr/Radarr.cs index 43cb1ee51..db645d45b 100644 --- a/src/NzbDrone.Core/Applications/Radarr/Radarr.cs +++ b/src/NzbDrone.Core/Applications/Radarr/Radarr.cs @@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Radarr private readonly IRadarrV3Proxy _radarrV3Proxy; private readonly ICached> _schemaCache; private readonly IConfigFileProvider _configFileProvider; - private readonly IIndexerFactory _indexerFactory; public Radarr(ICacheManager cacheManager, IRadarrV3Proxy radarrV3Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger) - : base(appIndexerMapService, logger) + : base(appIndexerMapService, indexerFactory, logger) { _schemaCache = cacheManager.GetCache>(GetType()); _radarrV3Proxy = radarrV3Proxy; _configFileProvider = configFileProvider; - _indexerFactory = indexerFactory; } public override ValidationResult Test() @@ -120,7 +118,7 @@ namespace NzbDrone.Core.Applications.Radarr public override void AddIndexer(IndexerDefinition indexer) { - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty()) { @@ -163,7 +161,7 @@ namespace NzbDrone.Core.Applications.Radarr { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); diff --git a/src/NzbDrone.Core/Applications/Readarr/Readarr.cs b/src/NzbDrone.Core/Applications/Readarr/Readarr.cs index 12a6dc7d1..79ee5c52d 100644 --- a/src/NzbDrone.Core/Applications/Readarr/Readarr.cs +++ b/src/NzbDrone.Core/Applications/Readarr/Readarr.cs @@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Readarr private readonly ICached> _schemaCache; private readonly IReadarrV1Proxy _readarrV1Proxy; private readonly IConfigFileProvider _configFileProvider; - private readonly IIndexerFactory _indexerFactory; public Readarr(ICacheManager cacheManager, IReadarrV1Proxy readarrV1Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger) - : base(appIndexerMapService, logger) + : base(appIndexerMapService, indexerFactory, logger) { _schemaCache = cacheManager.GetCache>(GetType()); _readarrV1Proxy = readarrV1Proxy; _configFileProvider = configFileProvider; - _indexerFactory = indexerFactory; } public override ValidationResult Test() @@ -120,7 +118,7 @@ namespace NzbDrone.Core.Applications.Readarr public override void AddIndexer(IndexerDefinition indexer) { - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty()) { @@ -163,7 +161,7 @@ namespace NzbDrone.Core.Applications.Readarr { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); diff --git a/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs b/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs index 509fda8e1..0e554ba83 100644 --- a/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs +++ b/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs @@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Sonarr private readonly ICached> _schemaCache; private readonly ISonarrV3Proxy _sonarrV3Proxy; private readonly IConfigFileProvider _configFileProvider; - private readonly IIndexerFactory _indexerFactory; public Sonarr(ICacheManager cacheManager, ISonarrV3Proxy sonarrV3Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger) - : base(appIndexerMapService, logger) + : base(appIndexerMapService, indexerFactory, logger) { _schemaCache = cacheManager.GetCache>(GetType()); _sonarrV3Proxy = sonarrV3Proxy; _configFileProvider = configFileProvider; - _indexerFactory = indexerFactory; } public override ValidationResult Test() @@ -124,7 +122,7 @@ namespace NzbDrone.Core.Applications.Sonarr public override void AddIndexer(IndexerDefinition indexer) { - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty() && indexerCapabilities.Categories.SupportedCategories(Settings.AnimeSyncCategories.ToArray()).Empty()) @@ -168,7 +166,7 @@ namespace NzbDrone.Core.Applications.Sonarr { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); diff --git a/src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs b/src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs index 75d98045a..d864152b2 100644 --- a/src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs +++ b/src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs @@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Whisparr private readonly IWhisparrV3Proxy _whisparrV3Proxy; private readonly ICached> _schemaCache; private readonly IConfigFileProvider _configFileProvider; - private readonly IIndexerFactory _indexerFactory; public Whisparr(ICacheManager cacheManager, IWhisparrV3Proxy whisparrV3Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger) - : base(appIndexerMapService, logger) + : base(appIndexerMapService, indexerFactory, logger) { _schemaCache = cacheManager.GetCache>(GetType()); _whisparrV3Proxy = whisparrV3Proxy; _configFileProvider = configFileProvider; - _indexerFactory = indexerFactory; } public override ValidationResult Test() @@ -120,7 +118,7 @@ namespace NzbDrone.Core.Applications.Whisparr public override void AddIndexer(IndexerDefinition indexer) { - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty()) { @@ -163,7 +161,7 @@ namespace NzbDrone.Core.Applications.Whisparr { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); - var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities(); + var indexerCapabilities = GetIndexerCapabilities(indexer); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id);