From 50616f5c9e95de450dc520b6a49f7af81bd68b38 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 18 Dec 2022 20:46:43 -0600 Subject: [PATCH] Fixed: Don't mess with options we don't set on full sync --- src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs | 8 +++++++- src/NzbDrone.Core/Applications/Radarr/Radarr.cs | 8 +++++++- src/NzbDrone.Core/Applications/Readarr/Readarr.cs | 8 +++++++- src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs | 7 ++++++- src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs | 8 +++++++- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs b/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs index 8ff099786..ec5421931 100644 --- a/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs +++ b/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Applications.Whisparr; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers; @@ -126,6 +127,8 @@ namespace NzbDrone.Core.Applications.Lidarr { if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) { + lidarrIndexer.Fields.AddRange(remoteIndexer.Fields.Where(f => !lidarrIndexer.Fields.Any(s => s.Name == f.Name))); + // Update the indexer if it still has categories that match _lidarrV1Proxy.UpdateIndexer(lidarrIndexer, Settings); } @@ -159,6 +162,7 @@ namespace NzbDrone.Core.Applications.Lidarr { var cacheKey = $"{Settings.BaseUrl}"; var schemas = _schemaCache.Get(cacheKey, () => _lidarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var syncFields = new string[] { "baseUrl", "apiPath", "apiKey", "categories", "minimumSeeders", "seedCriteria.seedRatio", "seedCriteria.seedTime", "seedCriteria.discographySeedTime" }; var newznab = schemas.Where(i => i.Implementation == "Newznab").First(); var torznab = schemas.Where(i => i.Implementation == "Torznab").First(); @@ -175,9 +179,11 @@ namespace NzbDrone.Core.Applications.Lidarr Priority = indexer.Priority, Implementation = indexer.Protocol == DownloadProtocol.Usenet ? "Newznab" : "Torznab", ConfigContract = schema.ConfigContract, - Fields = schema.Fields, + Fields = new List() }; + lidarrIndexer.Fields.AddRange(schema.Fields.Where(x => syncFields.Contains(x.Name))); + lidarrIndexer.Fields.FirstOrDefault(x => x.Name == "baseUrl").Value = $"{Settings.ProwlarrUrl.TrimEnd('/')}/{indexer.Id}/"; lidarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiPath").Value = "/api"; lidarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey; diff --git a/src/NzbDrone.Core/Applications/Radarr/Radarr.cs b/src/NzbDrone.Core/Applications/Radarr/Radarr.cs index 13e4ffe8a..7faaeb663 100644 --- a/src/NzbDrone.Core/Applications/Radarr/Radarr.cs +++ b/src/NzbDrone.Core/Applications/Radarr/Radarr.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Applications.Whisparr; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers; @@ -126,6 +127,8 @@ namespace NzbDrone.Core.Applications.Radarr { if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) { + radarrIndexer.Fields.AddRange(remoteIndexer.Fields.Where(f => !radarrIndexer.Fields.Any(s => s.Name == f.Name))); + // Update the indexer if it still has categories that match _radarrV3Proxy.UpdateIndexer(radarrIndexer, Settings); } @@ -159,6 +162,7 @@ namespace NzbDrone.Core.Applications.Radarr { var cacheKey = $"{Settings.BaseUrl}"; var schemas = _schemaCache.Get(cacheKey, () => _radarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var syncFields = new string[] { "baseUrl", "apiPath", "apiKey", "categories", "minimumSeeders", "seedCriteria.seedRatio", "seedCriteria.seedTime" }; var newznab = schemas.Where(i => i.Implementation == "Newznab").First(); var torznab = schemas.Where(i => i.Implementation == "Torznab").First(); @@ -175,9 +179,11 @@ namespace NzbDrone.Core.Applications.Radarr Priority = indexer.Priority, Implementation = indexer.Protocol == DownloadProtocol.Usenet ? "Newznab" : "Torznab", ConfigContract = schema.ConfigContract, - Fields = schema.Fields, + Fields = new List() }; + radarrIndexer.Fields.AddRange(schema.Fields.Where(x => syncFields.Contains(x.Name))); + radarrIndexer.Fields.FirstOrDefault(x => x.Name == "baseUrl").Value = $"{Settings.ProwlarrUrl.TrimEnd('/')}/{indexer.Id}/"; radarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiPath").Value = "/api"; radarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey; diff --git a/src/NzbDrone.Core/Applications/Readarr/Readarr.cs b/src/NzbDrone.Core/Applications/Readarr/Readarr.cs index 40cc9cc35..ca0fa7f6b 100644 --- a/src/NzbDrone.Core/Applications/Readarr/Readarr.cs +++ b/src/NzbDrone.Core/Applications/Readarr/Readarr.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Applications.Whisparr; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers; @@ -126,6 +127,8 @@ namespace NzbDrone.Core.Applications.Readarr { if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) { + readarrIndexer.Fields.AddRange(remoteIndexer.Fields.Where(f => !readarrIndexer.Fields.Any(s => s.Name == f.Name))); + // Update the indexer if it still has categories that match _readarrV1Proxy.UpdateIndexer(readarrIndexer, Settings); } @@ -159,6 +162,7 @@ namespace NzbDrone.Core.Applications.Readarr { var cacheKey = $"{Settings.BaseUrl}"; var schemas = _schemaCache.Get(cacheKey, () => _readarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var syncFields = new string[] { "baseUrl", "apiPath", "apiKey", "categories", "minimumSeeders", "seedCriteria.seedRatio", "seedCriteria.seedTime", "seedCriteria.discographySeedTime" }; var newznab = schemas.Where(i => i.Implementation == "Newznab").First(); var torznab = schemas.Where(i => i.Implementation == "Torznab").First(); @@ -175,9 +179,11 @@ namespace NzbDrone.Core.Applications.Readarr Priority = indexer.Priority, Implementation = indexer.Protocol == DownloadProtocol.Usenet ? "Newznab" : "Torznab", ConfigContract = schema.ConfigContract, - Fields = schema.Fields, + Fields = new List() }; + readarrIndexer.Fields.AddRange(schema.Fields.Where(x => syncFields.Contains(x.Name))); + readarrIndexer.Fields.FirstOrDefault(x => x.Name == "baseUrl").Value = $"{Settings.ProwlarrUrl.TrimEnd('/')}/{indexer.Id}/"; readarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiPath").Value = "/api"; readarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey; diff --git a/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs b/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs index 4b62bdad7..1ee7e5f8b 100644 --- a/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs +++ b/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs @@ -127,6 +127,8 @@ namespace NzbDrone.Core.Applications.Sonarr if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any() || indexer.Capabilities.Categories.SupportedCategories(Settings.AnimeSyncCategories.ToArray()).Any()) { // Update the indexer if it still has categories that match + sonarrIndexer.Fields.AddRange(remoteIndexer.Fields.Where(f => !sonarrIndexer.Fields.Any(s => s.Name == f.Name))); + _sonarrV3Proxy.UpdateIndexer(sonarrIndexer, Settings); } else @@ -159,6 +161,7 @@ namespace NzbDrone.Core.Applications.Sonarr { var cacheKey = $"{Settings.BaseUrl}"; var schemas = _schemaCache.Get(cacheKey, () => _sonarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var syncFields = new string[] { "baseUrl", "apiPath", "apiKey", "categories", "animeCategories", "minimumSeeders", "seedCriteria.seedRatio", "seedCriteria.seedTime", "seedCriteria.seasonPackSeedTime" }; var newznab = schemas.Where(i => i.Implementation == "Newznab").First(); var torznab = schemas.Where(i => i.Implementation == "Torznab").First(); @@ -175,9 +178,11 @@ namespace NzbDrone.Core.Applications.Sonarr Priority = indexer.Priority, Implementation = indexer.Protocol == DownloadProtocol.Usenet ? "Newznab" : "Torznab", ConfigContract = schema.ConfigContract, - Fields = schema.Fields, + Fields = new List() }; + sonarrIndexer.Fields.AddRange(schema.Fields.Where(x => syncFields.Contains(x.Name))); + sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "baseUrl").Value = $"{Settings.ProwlarrUrl.TrimEnd('/')}/{indexer.Id}/"; sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiPath").Value = "/api"; sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey; diff --git a/src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs b/src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs index ff6a5966a..cc2ad5d61 100644 --- a/src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs +++ b/src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Applications.Sonarr; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers; @@ -126,6 +127,8 @@ namespace NzbDrone.Core.Applications.Whisparr { if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) { + whisparrIndexer.Fields.AddRange(remoteIndexer.Fields.Where(f => !whisparrIndexer.Fields.Any(s => s.Name == f.Name))); + // Update the indexer if it still has categories that match _whisparrV3Proxy.UpdateIndexer(whisparrIndexer, Settings); } @@ -159,6 +162,7 @@ namespace NzbDrone.Core.Applications.Whisparr { var cacheKey = $"{Settings.BaseUrl}"; var schemas = _schemaCache.Get(cacheKey, () => _whisparrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); + var syncFields = new string[] { "baseUrl", "apiPath", "apiKey", "categories", "minimumSeeders", "seedCriteria.seedRatio", "seedCriteria.seedTime" }; var newznab = schemas.Where(i => i.Implementation == "Newznab").First(); var torznab = schemas.Where(i => i.Implementation == "Torznab").First(); @@ -175,9 +179,11 @@ namespace NzbDrone.Core.Applications.Whisparr Priority = indexer.Priority, Implementation = indexer.Protocol == DownloadProtocol.Usenet ? "Newznab" : "Torznab", ConfigContract = schema.ConfigContract, - Fields = schema.Fields, + Fields = new List() }; + whisparrIndexer.Fields.AddRange(schema.Fields.Where(x => syncFields.Contains(x.Name))); + whisparrIndexer.Fields.FirstOrDefault(x => x.Name == "baseUrl").Value = $"{Settings.ProwlarrUrl.TrimEnd('/')}/{indexer.Id}/"; whisparrIndexer.Fields.FirstOrDefault(x => x.Name == "apiPath").Value = "/api"; whisparrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey;