mirror of
https://github.com/Radarr/Radarr
synced 2025-02-25 07:32:56 +00:00
Fixed: Adding indexers from presets
This commit is contained in:
parent
88b9a47c79
commit
3a146ea667
18 changed files with 32 additions and 28 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace NzbDrone.Api.DownloadClient
|
||||
{
|
||||
public class DownloadClientResource : ProviderResource
|
||||
public class DownloadClientResource : ProviderResource<DownloadClientResource>
|
||||
{
|
||||
public bool Enable { get; set; }
|
||||
public DownloadProtocol Protocol { get; set; }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace NzbDrone.Api.Indexers
|
||||
{
|
||||
public class IndexerResource : ProviderResource
|
||||
public class IndexerResource : ProviderResource<IndexerResource>
|
||||
{
|
||||
public bool EnableRss { get; set; }
|
||||
public bool EnableSearch { get; set; }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace NzbDrone.Api.Metadata
|
||||
{
|
||||
public class MetadataResource : ProviderResource
|
||||
public class MetadataResource : ProviderResource<MetadataResource>
|
||||
{
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace NzbDrone.Api.ImportList
|
||||
{
|
||||
public class ImportExclusionsResource : ProviderResource
|
||||
public class ImportExclusionsResource : ProviderResource<ImportExclusionsResource>
|
||||
{
|
||||
//public int Id { get; set; }
|
||||
public int TmdbId { get; set; }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace NzbDrone.Api.ImportList
|
||||
{
|
||||
public class ImportListResource : ProviderResource
|
||||
public class ImportListResource : ProviderResource<ImportListResource>
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public bool EnableAuto { get; set; }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace NzbDrone.Api.Notifications
|
||||
{
|
||||
public class NotificationResource : ProviderResource
|
||||
public class NotificationResource : ProviderResource<NotificationResource>
|
||||
{
|
||||
public bool OnGrab { get; set; }
|
||||
public bool OnDownload { get; set; }
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Api
|
|||
public abstract class ProviderModuleBase<TProviderResource, TProvider, TProviderDefinition> : RadarrRestModule<TProviderResource>
|
||||
where TProviderDefinition : ProviderDefinition, new()
|
||||
where TProvider : IProvider
|
||||
where TProviderResource : ProviderResource, new()
|
||||
where TProviderResource : ProviderResource<TProviderResource>, new()
|
||||
{
|
||||
private readonly IProviderFactory<TProvider, TProviderDefinition> _providerFactory;
|
||||
|
||||
|
@ -160,8 +160,7 @@ private object GetTemplates()
|
|||
{
|
||||
var presetResource = new TProviderResource();
|
||||
MapToResource(presetResource, v);
|
||||
|
||||
return presetResource as ProviderResource;
|
||||
return presetResource;
|
||||
}).ToList();
|
||||
|
||||
result.Add(providerResource);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace NzbDrone.Api
|
||||
{
|
||||
public class ProviderResource : RestResource
|
||||
public class ProviderResource<T> : RestResource
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public List<Field> Fields { get; set; }
|
||||
|
@ -15,6 +15,6 @@ public class ProviderResource : RestResource
|
|||
public string InfoLink { get; set; }
|
||||
public ProviderMessage Message { get; set; }
|
||||
|
||||
public List<ProviderResource> Presets { get; set; }
|
||||
public List<T> Presets { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public class PolymorphicWriteOnlyJsonConverter<T> : JsonConverter<T>
|
|||
{
|
||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return JsonSerializer.Deserialize<T>(ref reader, options);
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||||
|
|
|
@ -53,6 +53,14 @@ private Field GetCategoriesField(IndexerResource resource)
|
|||
return field;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void all_preset_fields_should_be_set_correctly()
|
||||
{
|
||||
var schema = GetNewznabSchemav3();
|
||||
|
||||
schema.Presets.Any(x => x.SupportsRss).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void v2_categories_should_be_array()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace Radarr.Api.V3.DownloadClient
|
||||
{
|
||||
public class DownloadClientResource : ProviderResource
|
||||
public class DownloadClientResource : ProviderResource<DownloadClientResource>
|
||||
{
|
||||
public bool Enable { get; set; }
|
||||
public DownloadProtocol Protocol { get; set; }
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Radarr.Api.V3.ImportLists
|
||||
{
|
||||
public class ImportExclusionsResource : ProviderResource
|
||||
public class ImportExclusionsResource : ProviderResource<ImportExclusionsResource>
|
||||
{
|
||||
//public int Id { get; set; }
|
||||
public int TmdbId { get; set; }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace Radarr.Api.V3.ImportLists
|
||||
{
|
||||
public class ImportListResource : ProviderResource
|
||||
public class ImportListResource : ProviderResource<ImportListResource>
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public bool EnableAuto { get; set; }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Radarr.Api.V3.Indexers
|
||||
{
|
||||
public class IndexerResource : ProviderResource
|
||||
public class IndexerResource : ProviderResource<IndexerResource>
|
||||
{
|
||||
public bool EnableRss { get; set; }
|
||||
public bool EnableAutomaticSearch { get; set; }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Radarr.Api.V3.Metadata
|
||||
{
|
||||
public class MetadataResource : ProviderResource
|
||||
public class MetadataResource : ProviderResource<MetadataResource>
|
||||
{
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Radarr.Api.V3.Notifications
|
||||
{
|
||||
public class NotificationResource : ProviderResource
|
||||
public class NotificationResource : ProviderResource<NotificationResource>
|
||||
{
|
||||
public string Link { get; set; }
|
||||
public bool OnGrab { get; set; }
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Radarr.Api.V3
|
|||
public abstract class ProviderModuleBase<TProviderResource, TProvider, TProviderDefinition> : RadarrRestModule<TProviderResource>
|
||||
where TProviderDefinition : ProviderDefinition, new()
|
||||
where TProvider : IProvider
|
||||
where TProviderResource : ProviderResource, new()
|
||||
where TProviderResource : ProviderResource<TProviderResource>, new()
|
||||
{
|
||||
private readonly IProviderFactory<TProvider, TProviderDefinition> _providerFactory;
|
||||
private readonly ProviderResourceMapper<TProviderResource, TProviderDefinition> _resourceMapper;
|
||||
|
@ -124,12 +124,9 @@ private object GetTemplates()
|
|||
var providerResource = _resourceMapper.ToResource(providerDefinition);
|
||||
var presetDefinitions = _providerFactory.GetPresetDefinitions(providerDefinition);
|
||||
|
||||
providerResource.Presets = presetDefinitions.Select(v =>
|
||||
{
|
||||
var presetResource = _resourceMapper.ToResource(v);
|
||||
|
||||
return presetResource as ProviderResource;
|
||||
}).ToList();
|
||||
providerResource.Presets = presetDefinitions
|
||||
.Select(v => _resourceMapper.ToResource(v))
|
||||
.ToList();
|
||||
|
||||
result.Add(providerResource);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace Radarr.Api.V3
|
||||
{
|
||||
public class ProviderResource : RestResource
|
||||
public class ProviderResource<T> : RestResource
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public List<Field> Fields { get; set; }
|
||||
|
@ -17,11 +17,11 @@ public class ProviderResource : RestResource
|
|||
public ProviderMessage Message { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
|
||||
public List<ProviderResource> Presets { get; set; }
|
||||
public List<T> Presets { get; set; }
|
||||
}
|
||||
|
||||
public class ProviderResourceMapper<TProviderResource, TProviderDefinition>
|
||||
where TProviderResource : ProviderResource, new()
|
||||
where TProviderResource : ProviderResource<TProviderResource>, new()
|
||||
where TProviderDefinition : ProviderDefinition, new()
|
||||
{
|
||||
public virtual TProviderResource ToResource(TProviderDefinition definition)
|
||||
|
|
Loading…
Reference in a new issue