Fixed: Don't Add if Indexer doesn't support Apps categories

This commit is contained in:
Qstick
2021-03-01 22:20:06 -05:00
parent 696489731b
commit 39b9381f77
9 changed files with 66 additions and 29 deletions

View File

@@ -0,0 +1,10 @@
using System.Collections.Generic;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Applications
{
public interface IApplicationSettings : IProviderConfig
{
IEnumerable<int> SyncCategories { get; set; }
}
}

View File

@@ -38,14 +38,17 @@ namespace NzbDrone.Core.Applications.Lidarr
public override void AddIndexer(IndexerDefinition indexer) public override void AddIndexer(IndexerDefinition indexer)
{ {
var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _lidarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any())
var newznab = schema.Where(i => i.Implementation == "Newznab").First(); {
var torznab = schema.Where(i => i.Implementation == "Torznab").First(); 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); var remoteIndexer = _lidarrV1Proxy.AddIndexer(lidarrIndexer, Settings);
_appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id });
}
} }
public override void RemoveIndexer(int indexerId) public override void RemoveIndexer(int indexerId)

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; 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(); private static readonly LidarrSettingsValidator Validator = new LidarrSettingsValidator();
@@ -23,8 +24,11 @@ namespace NzbDrone.Core.Applications.Lidarr
{ {
ProwlarrUrl = "http://localhost:9696"; ProwlarrUrl = "http://localhost:9696";
BaseUrl = "http://localhost:8686"; BaseUrl = "http://localhost:8686";
SyncCategories = new[] { 3000, 3010, 3030, 3040, 3050, 3060 };
} }
public IEnumerable<int> SyncCategories { get; set; }
[FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Lidarr sees it, including http(s):// and port if needed")] [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; } public string ProwlarrUrl { get; set; }

View File

@@ -38,14 +38,17 @@ namespace NzbDrone.Core.Applications.Radarr
public override void AddIndexer(IndexerDefinition indexer) public override void AddIndexer(IndexerDefinition indexer)
{ {
var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _radarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any())
var newznab = schema.Where(i => i.Implementation == "Newznab").First(); {
var torznab = schema.Where(i => i.Implementation == "Torznab").First(); 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); var remoteIndexer = _radarrV3Proxy.AddIndexer(radarrIndexer, Settings);
_appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id });
}
} }
public override void RemoveIndexer(int indexerId) public override void RemoveIndexer(int indexerId)

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; 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(); private static readonly RadarrSettingsValidator Validator = new RadarrSettingsValidator();
@@ -23,8 +24,11 @@ namespace NzbDrone.Core.Applications.Radarr
{ {
ProwlarrUrl = "http://localhost:9696"; ProwlarrUrl = "http://localhost:9696";
BaseUrl = "http://localhost:7878"; BaseUrl = "http://localhost:7878";
SyncCategories = new[] { 2000, 2010, 2020, 2030, 2040, 2045, 2050, 2060, 2070, 2080 };
} }
public IEnumerable<int> SyncCategories { get; set; }
[FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Radarr sees it, including http(s):// and port if needed")] [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; } public string ProwlarrUrl { get; set; }

View File

@@ -38,14 +38,17 @@ namespace NzbDrone.Core.Applications.Readarr
public override void AddIndexer(IndexerDefinition indexer) public override void AddIndexer(IndexerDefinition indexer)
{ {
var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _readarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any())
var newznab = schema.Where(i => i.Implementation == "Newznab").First(); {
var torznab = schema.Where(i => i.Implementation == "Torznab").First(); 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); var remoteIndexer = _readarrV1Proxy.AddIndexer(readarrIndexer, Settings);
_appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id });
}
} }
public override void RemoveIndexer(int indexerId) public override void RemoveIndexer(int indexerId)

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Applications.Readarr 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(); private static readonly ReadarrSettingsValidator Validator = new ReadarrSettingsValidator();
@@ -23,8 +23,11 @@ namespace NzbDrone.Core.Applications.Readarr
{ {
ProwlarrUrl = "http://localhost:9696"; ProwlarrUrl = "http://localhost:9696";
BaseUrl = "http://localhost:8787"; BaseUrl = "http://localhost:8787";
SyncCategories = new[] { 7000, 7010, 7020, 7030, 7040, 7050, 7060 };
} }
public IEnumerable<int> SyncCategories { get; set; }
[FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Readarr sees it, including http(s):// and port if needed")] [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; } public string ProwlarrUrl { get; set; }

View File

@@ -38,14 +38,17 @@ namespace NzbDrone.Core.Applications.Sonarr
public override void AddIndexer(IndexerDefinition indexer) public override void AddIndexer(IndexerDefinition indexer)
{ {
var schema = _schemaCache.Get(Definition.Settings.ToJson(), () => _sonarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any())
var newznab = schema.Where(i => i.Implementation == "Newznab").First(); {
var torznab = schema.Where(i => i.Implementation == "Torznab").First(); 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); var remoteIndexer = _sonarrV3Proxy.AddIndexer(sonarrIndexer, Settings);
_appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id });
}
} }
public override void RemoveIndexer(int indexerId) public override void RemoveIndexer(int indexerId)

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; 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(); private static readonly SonarrSettingsValidator Validator = new SonarrSettingsValidator();
@@ -23,8 +24,11 @@ namespace NzbDrone.Core.Applications.Sonarr
{ {
ProwlarrUrl = "http://localhost:9696"; ProwlarrUrl = "http://localhost:9696";
BaseUrl = "http://localhost:8989"; BaseUrl = "http://localhost:8989";
SyncCategories = new[] { 5000, 5010, 5020, 5030, 5040, 5045, 5050, 5070 };
} }
public IEnumerable<int> SyncCategories { get; set; }
[FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Sonarr sees it, including http(s):// and port if needed")] [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; } public string ProwlarrUrl { get; set; }