2020-07-13 20:04:59 +00:00
|
|
|
|
using FluentValidation;
|
|
|
|
|
using NzbDrone.Core.Annotations;
|
|
|
|
|
using NzbDrone.Core.ThingiProvider;
|
|
|
|
|
using NzbDrone.Core.Validation;
|
|
|
|
|
|
2020-09-04 02:50:56 +00:00
|
|
|
|
namespace NzbDrone.Core.ImportLists.RadarrList2.IMDbList
|
2020-07-13 20:04:59 +00:00
|
|
|
|
{
|
|
|
|
|
public class IMDbSettingsValidator : AbstractValidator<IMDbListSettings>
|
|
|
|
|
{
|
|
|
|
|
public IMDbSettingsValidator()
|
|
|
|
|
{
|
|
|
|
|
RuleFor(c => c.ListId)
|
|
|
|
|
.Matches(@"^top250$|^popular$|^ls\d+$|^ur\d+$")
|
|
|
|
|
.WithMessage("List ID mist be 'top250', 'popular', an IMDb List ID of the form 'ls12345678' or an IMDb user watchlist of the form 'ur12345678'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class IMDbListSettings : IProviderConfig
|
|
|
|
|
{
|
|
|
|
|
private static readonly IMDbSettingsValidator Validator = new IMDbSettingsValidator();
|
|
|
|
|
|
|
|
|
|
public IMDbListSettings()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[FieldDefinition(1, Label = "List/User ID", HelpText = "IMDb list ID (e.g ls12345678), IMDb user ID (e.g. ur12345678), 'top250' or 'popular'")]
|
|
|
|
|
public string ListId { get; set; }
|
|
|
|
|
|
|
|
|
|
public NzbDroneValidationResult Validate()
|
|
|
|
|
{
|
|
|
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|