mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-10-02 16:52:04 +02:00
47 lines
1.7 KiB
C#
47 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using FluentValidation;
|
|
using NzbDrone.Core.Annotations;
|
|
using NzbDrone.Core.ThingiProvider;
|
|
using NzbDrone.Core.Validation;
|
|
|
|
namespace NzbDrone.Core.Applications.Radarr
|
|
{
|
|
public class RadarrSettingsValidator : AbstractValidator<RadarrSettings>
|
|
{
|
|
public RadarrSettingsValidator()
|
|
{
|
|
RuleFor(c => c.BaseUrl).IsValidUrl();
|
|
RuleFor(c => c.ProwlarrUrl).IsValidUrl();
|
|
RuleFor(c => c.ApiKey).NotEmpty();
|
|
}
|
|
}
|
|
|
|
public class RadarrSettings : IApplicationSettings
|
|
{
|
|
private static readonly RadarrSettingsValidator Validator = new RadarrSettingsValidator();
|
|
|
|
public RadarrSettings()
|
|
{
|
|
ProwlarrUrl = "http://localhost:9696";
|
|
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")]
|
|
public string ProwlarrUrl { get; set; }
|
|
|
|
[FieldDefinition(1, Label = "Radarr Server", HelpText = "Radarr server URL, including http(s):// and port if needed")]
|
|
public string BaseUrl { get; set; }
|
|
|
|
[FieldDefinition(2, Label = "ApiKey", Privacy = PrivacyLevel.ApiKey, HelpText = "The ApiKey generated by Radarr in Settings/General")]
|
|
public string ApiKey { get; set; }
|
|
|
|
public NzbDroneValidationResult Validate()
|
|
{
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
}
|
|
}
|
|
}
|