You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
2.3 KiB
52 lines
2.3 KiB
using System.Collections.Generic;
|
|
using FluentValidation;
|
|
using NzbDrone.Core.Annotations;
|
|
using NzbDrone.Core.Indexers;
|
|
using NzbDrone.Core.Validation;
|
|
|
|
namespace NzbDrone.Core.Applications.Whisparr
|
|
{
|
|
public class WhisparrSettingsValidator : AbstractValidator<WhisparrSettings>
|
|
{
|
|
public WhisparrSettingsValidator()
|
|
{
|
|
RuleFor(c => c.BaseUrl).IsValidUrl();
|
|
RuleFor(c => c.ProwlarrUrl).IsValidUrl();
|
|
RuleFor(c => c.ApiKey).NotEmpty();
|
|
RuleFor(c => c.SyncCategories).NotEmpty();
|
|
}
|
|
}
|
|
|
|
public class WhisparrSettings : IApplicationSettings
|
|
{
|
|
private static readonly WhisparrSettingsValidator Validator = new ();
|
|
|
|
public WhisparrSettings()
|
|
{
|
|
ProwlarrUrl = "http://localhost:9696";
|
|
BaseUrl = "http://localhost:6969";
|
|
SyncCategories = new[] { 6000, 6010, 6020, 6030, 6040, 6045, 6050, 6070, 6080, 6090 };
|
|
}
|
|
|
|
[FieldDefinition(0, Label = "Prowlarr Server", HelpText = "Prowlarr server URL as Whisparr sees it, including http(s)://, port, and urlbase if needed", Placeholder = "http://localhost:9696")]
|
|
public string ProwlarrUrl { get; set; }
|
|
|
|
[FieldDefinition(1, Label = "Whisparr Server", HelpText = "URL used to connect to Whisparr server, including http(s)://, port, and urlbase if required", Placeholder = "http://localhost:6969")]
|
|
public string BaseUrl { get; set; }
|
|
|
|
[FieldDefinition(2, Label = "API Key", Privacy = PrivacyLevel.ApiKey, HelpText = "The ApiKey generated by Whisparr in Settings/General")]
|
|
public string ApiKey { get; set; }
|
|
|
|
[FieldDefinition(3, Label = "Sync Categories", Type = FieldType.Select, SelectOptions = typeof(NewznabCategoryFieldConverter), HelpText = "Only Indexers that support these categories will be synced", Advanced = true)]
|
|
public IEnumerable<int> SyncCategories { get; set; }
|
|
|
|
[FieldDefinition(4, Type = FieldType.Checkbox, Label = "ApplicationSettingsSyncRejectBlocklistedTorrentHashes", HelpText = "ApplicationSettingsSyncRejectBlocklistedTorrentHashesHelpText", Advanced = true)]
|
|
public bool SyncRejectBlocklistedTorrentHashesWhileGrabbing { get; set; }
|
|
|
|
public NzbDroneValidationResult Validate()
|
|
{
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
}
|
|
}
|
|
}
|