Radarr/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsSettings.cs

50 lines
1.7 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using FluentValidation;
2013-05-03 05:24:52 +00:00
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Validation;
2013-04-07 07:30:37 +00:00
namespace NzbDrone.Core.Indexers.Omgwtfnzbs
{
2013-08-26 04:01:03 +00:00
public class OmgwtfnzbsSettingsValidator : AbstractValidator<OmgwtfnzbsSettings>
{
public OmgwtfnzbsSettingsValidator()
{
RuleFor(c => c.Username).NotEmpty();
RuleFor(c => c.ApiKey).NotEmpty();
RuleFor(c => c.Delay).GreaterThanOrEqualTo(0);
2013-08-26 04:01:03 +00:00
}
}
public class OmgwtfnzbsSettings : IIndexerSettings
2013-04-07 07:30:37 +00:00
{
2013-08-26 04:01:03 +00:00
private static readonly OmgwtfnzbsSettingsValidator Validator = new OmgwtfnzbsSettingsValidator();
2013-08-22 08:08:43 +00:00
public OmgwtfnzbsSettings()
{
Delay = 30;
2019-10-14 21:47:23 +00:00
MultiLanguages = new List<int>();
}
// Unused since Omg has a hardcoded url.
public string BaseUrl { get; set; }
[FieldDefinition(0, Label = "Username", Privacy = PrivacyLevel.UserName)]
public string Username { get; set; }
2013-05-03 05:24:52 +00:00
[FieldDefinition(1, Label = "API Key", Privacy = PrivacyLevel.ApiKey)]
public string ApiKey { get; set; }
[FieldDefinition(2, Label = "Delay", HelpText = "Time in minutes to delay new nzbs before they appear on the RSS feed", Advanced = true)]
public int Delay { get; set; }
2019-12-22 21:24:11 +00:00
2020-12-20 15:21:51 +00:00
[FieldDefinition(3, Type = FieldType.Select, SelectOptions = typeof(RealLanguageFieldConverter), Label = "Multi Languages", HelpText = "What languages are normally in a multi release on this indexer?", Advanced = true)]
public IEnumerable<int> MultiLanguages { get; set; }
2013-04-07 07:30:37 +00:00
public NzbDroneValidationResult Validate()
2013-04-07 07:30:37 +00:00
{
return new NzbDroneValidationResult(Validator.Validate(this));
2013-04-07 07:30:37 +00:00
}
}
}