using System.Collections.Generic ;
using FluentValidation ;
using NzbDrone.Core.Annotations ;
using NzbDrone.Core.ThingiProvider ;
using NzbDrone.Core.Validation ;
using System.Text.RegularExpressions ;
using NzbDrone.Core.Parser.Model ;
namespace NzbDrone.Core.Indexers.PassThePopcorn
{
public class PassThePopcornSettingsValidator : AbstractValidator < PassThePopcornSettings >
{
public PassThePopcornSettingsValidator ( )
{
RuleFor ( c = > c . BaseUrl ) . ValidRootUrl ( ) ;
RuleFor ( c = > c . Username ) . NotEmpty ( ) ;
RuleFor ( c = > c . Password ) . NotEmpty ( ) ;
RuleFor ( c = > c . Passkey ) . NotEmpty ( ) ;
}
}
public class PassThePopcornSettings : ITorrentIndexerSettings
{
private static readonly PassThePopcornSettingsValidator Validator = new PassThePopcornSettingsValidator ( ) ;
public PassThePopcornSettings ( )
{
BaseUrl = "https://passthepopcorn.me" ;
MinimumSeeders = 0 ;
}
[FieldDefinition(0, Label = "URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your cookie will be sent to that host.")]
public string BaseUrl { get ; set ; }
[FieldDefinition(1, Label = "Username", HelpText = "PTP Username")]
public string Username { get ; set ; }
[FieldDefinition(2, Label = "Password", Type = FieldType.Password, HelpText = "PTP Password")]
public string Password { get ; set ; }
[FieldDefinition(3, Label = "Passkey", HelpText = "PTP Passkey")]
public string Passkey { get ; set ; }
[FieldDefinition(4, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get ; set ; }
[FieldDefinition(5, Type = FieldType.Tag, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", Advanced = true)]
public IEnumerable < int > RequiredFlags { get ; set ; }
public NzbDroneValidationResult Validate ( )
{
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
}
}
}