diff --git a/src/NzbDrone.Core/Applications/IApplicationSettings.cs b/src/NzbDrone.Core/Applications/IApplicationSettings.cs new file mode 100644 index 000000000..707bd143c --- /dev/null +++ b/src/NzbDrone.Core/Applications/IApplicationSettings.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using NzbDrone.Core.ThingiProvider; + +namespace NzbDrone.Core.Applications +{ + public interface IApplicationSettings : IProviderConfig + { + IEnumerable SyncCategories { get; set; } + } +} diff --git a/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs b/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs index c766a9aab..aa6c1c819 100644 --- a/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs +++ b/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs @@ -38,14 +38,17 @@ namespace NzbDrone.Core.Applications.Lidarr public override void AddIndexer(IndexerDefinition indexer) { - var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _lidarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); - var newznab = schema.Where(i => i.Implementation == "Newznab").First(); - var torznab = schema.Where(i => i.Implementation == "Torznab").First(); + if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) + { + var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _lidarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var newznab = schema.Where(i => i.Implementation == "Newznab").First(); + var torznab = schema.Where(i => i.Implementation == "Torznab").First(); - var lidarrIndexer = BuildLidarrIndexer(indexer, indexer.Protocol == DownloadProtocol.Usenet ? newznab : torznab); + var lidarrIndexer = BuildLidarrIndexer(indexer, indexer.Protocol == DownloadProtocol.Usenet ? newznab : torznab); - var remoteIndexer = _lidarrV1Proxy.AddIndexer(lidarrIndexer, Settings); - _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); + var remoteIndexer = _lidarrV1Proxy.AddIndexer(lidarrIndexer, Settings); + _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); + } } public override void RemoveIndexer(int indexerId) diff --git a/src/NzbDrone.Core/Applications/Lidarr/LidarrSettings.cs b/src/NzbDrone.Core/Applications/Lidarr/LidarrSettings.cs index 01c86683e..abb8afcf7 100644 --- a/src/NzbDrone.Core/Applications/Lidarr/LidarrSettings.cs +++ b/src/NzbDrone.Core/Applications/Lidarr/LidarrSettings.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -15,7 +16,7 @@ namespace NzbDrone.Core.Applications.Lidarr } } - public class LidarrSettings : IProviderConfig + public class LidarrSettings : IApplicationSettings { private static readonly LidarrSettingsValidator Validator = new LidarrSettingsValidator(); @@ -23,8 +24,11 @@ namespace NzbDrone.Core.Applications.Lidarr { ProwlarrUrl = "http://localhost:9696"; BaseUrl = "http://localhost:8686"; + SyncCategories = new[] { 3000, 3010, 3030, 3040, 3050, 3060 }; } + public IEnumerable SyncCategories { get; set; } + [FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Lidarr sees it, including http(s):// and port if needed")] public string ProwlarrUrl { get; set; } diff --git a/src/NzbDrone.Core/Applications/Radarr/Radarr.cs b/src/NzbDrone.Core/Applications/Radarr/Radarr.cs index 38db98428..3e9225e87 100644 --- a/src/NzbDrone.Core/Applications/Radarr/Radarr.cs +++ b/src/NzbDrone.Core/Applications/Radarr/Radarr.cs @@ -38,14 +38,17 @@ namespace NzbDrone.Core.Applications.Radarr public override void AddIndexer(IndexerDefinition indexer) { - var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _radarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); - var newznab = schema.Where(i => i.Implementation == "Newznab").First(); - var torznab = schema.Where(i => i.Implementation == "Torznab").First(); + if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) + { + var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _radarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var newznab = schema.Where(i => i.Implementation == "Newznab").First(); + var torznab = schema.Where(i => i.Implementation == "Torznab").First(); - var radarrIndexer = BuildRadarrIndexer(indexer, indexer.Protocol == DownloadProtocol.Usenet ? newznab : torznab); + var radarrIndexer = BuildRadarrIndexer(indexer, indexer.Protocol == DownloadProtocol.Usenet ? newznab : torznab); - var remoteIndexer = _radarrV3Proxy.AddIndexer(radarrIndexer, Settings); - _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); + var remoteIndexer = _radarrV3Proxy.AddIndexer(radarrIndexer, Settings); + _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); + } } public override void RemoveIndexer(int indexerId) diff --git a/src/NzbDrone.Core/Applications/Radarr/RadarrSettings.cs b/src/NzbDrone.Core/Applications/Radarr/RadarrSettings.cs index 40d1927b6..05c56e228 100644 --- a/src/NzbDrone.Core/Applications/Radarr/RadarrSettings.cs +++ b/src/NzbDrone.Core/Applications/Radarr/RadarrSettings.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -15,7 +16,7 @@ namespace NzbDrone.Core.Applications.Radarr } } - public class RadarrSettings : IProviderConfig + public class RadarrSettings : IApplicationSettings { private static readonly RadarrSettingsValidator Validator = new RadarrSettingsValidator(); @@ -23,8 +24,11 @@ namespace NzbDrone.Core.Applications.Radarr { ProwlarrUrl = "http://localhost:9696"; BaseUrl = "http://localhost:7878"; + SyncCategories = new[] { 2000, 2010, 2020, 2030, 2040, 2045, 2050, 2060, 2070, 2080 }; } + public IEnumerable SyncCategories { get; set; } + [FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Radarr sees it, including http(s):// and port if needed")] public string ProwlarrUrl { get; set; } diff --git a/src/NzbDrone.Core/Applications/Readarr/Readarr.cs b/src/NzbDrone.Core/Applications/Readarr/Readarr.cs index e9dffdd94..45839d424 100644 --- a/src/NzbDrone.Core/Applications/Readarr/Readarr.cs +++ b/src/NzbDrone.Core/Applications/Readarr/Readarr.cs @@ -38,14 +38,17 @@ namespace NzbDrone.Core.Applications.Readarr public override void AddIndexer(IndexerDefinition indexer) { - var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _readarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); - var newznab = schema.Where(i => i.Implementation == "Newznab").First(); - var torznab = schema.Where(i => i.Implementation == "Torznab").First(); + if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) + { + var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _readarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var newznab = schema.Where(i => i.Implementation == "Newznab").First(); + var torznab = schema.Where(i => i.Implementation == "Torznab").First(); - var readarrIndexer = BuildReadarrIndexer(indexer, indexer.Protocol == DownloadProtocol.Usenet ? newznab : torznab); + var readarrIndexer = BuildReadarrIndexer(indexer, indexer.Protocol == DownloadProtocol.Usenet ? newznab : torznab); - var remoteIndexer = _readarrV1Proxy.AddIndexer(readarrIndexer, Settings); - _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); + var remoteIndexer = _readarrV1Proxy.AddIndexer(readarrIndexer, Settings); + _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); + } } public override void RemoveIndexer(int indexerId) diff --git a/src/NzbDrone.Core/Applications/Readarr/ReadarrSettings.cs b/src/NzbDrone.Core/Applications/Readarr/ReadarrSettings.cs index 971e37a14..3ed78b5d8 100644 --- a/src/NzbDrone.Core/Applications/Readarr/ReadarrSettings.cs +++ b/src/NzbDrone.Core/Applications/Readarr/ReadarrSettings.cs @@ -1,6 +1,6 @@ +using System.Collections.Generic; using FluentValidation; using NzbDrone.Core.Annotations; -using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Applications.Readarr @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Applications.Readarr } } - public class ReadarrSettings : IProviderConfig + public class ReadarrSettings : IApplicationSettings { private static readonly ReadarrSettingsValidator Validator = new ReadarrSettingsValidator(); @@ -23,8 +23,11 @@ namespace NzbDrone.Core.Applications.Readarr { ProwlarrUrl = "http://localhost:9696"; BaseUrl = "http://localhost:8787"; + SyncCategories = new[] { 7000, 7010, 7020, 7030, 7040, 7050, 7060 }; } + public IEnumerable SyncCategories { get; set; } + [FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Readarr sees it, including http(s):// and port if needed")] public string ProwlarrUrl { get; set; } diff --git a/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs b/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs index cdc9506c9..35b14077f 100644 --- a/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs +++ b/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs @@ -38,14 +38,17 @@ namespace NzbDrone.Core.Applications.Sonarr public override void AddIndexer(IndexerDefinition indexer) { - var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _sonarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); - var newznab = schema.Where(i => i.Implementation == "Newznab").First(); - var torznab = schema.Where(i => i.Implementation == "Torznab").First(); + if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) + { + var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _sonarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var newznab = schema.Where(i => i.Implementation == "Newznab").First(); + var torznab = schema.Where(i => i.Implementation == "Torznab").First(); - var sonarrIndexer = BuildSonarrIndexer(indexer, indexer.Protocol == DownloadProtocol.Usenet ? newznab : torznab); + var sonarrIndexer = BuildSonarrIndexer(indexer, indexer.Protocol == DownloadProtocol.Usenet ? newznab : torznab); - var remoteIndexer = _sonarrV3Proxy.AddIndexer(sonarrIndexer, Settings); - _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); + var remoteIndexer = _sonarrV3Proxy.AddIndexer(sonarrIndexer, Settings); + _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); + } } public override void RemoveIndexer(int indexerId) diff --git a/src/NzbDrone.Core/Applications/Sonarr/SonarrSettings.cs b/src/NzbDrone.Core/Applications/Sonarr/SonarrSettings.cs index 003ef72ce..dddeab7f1 100644 --- a/src/NzbDrone.Core/Applications/Sonarr/SonarrSettings.cs +++ b/src/NzbDrone.Core/Applications/Sonarr/SonarrSettings.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -15,7 +16,7 @@ namespace NzbDrone.Core.Applications.Sonarr } } - public class SonarrSettings : IProviderConfig + public class SonarrSettings : IApplicationSettings { private static readonly SonarrSettingsValidator Validator = new SonarrSettingsValidator(); @@ -23,8 +24,11 @@ namespace NzbDrone.Core.Applications.Sonarr { ProwlarrUrl = "http://localhost:9696"; BaseUrl = "http://localhost:8989"; + SyncCategories = new[] { 5000, 5010, 5020, 5030, 5040, 5045, 5050, 5070 }; } + public IEnumerable SyncCategories { get; set; } + [FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Sonarr sees it, including http(s):// and port if needed")] public string ProwlarrUrl { get; set; }