2018-11-23 07:03:32 +00:00
using System.Collections.Generic ;
2018-02-01 13:18:52 +00:00
using FluentValidation ;
2017-01-09 13:30:15 +00:00
using NzbDrone.Core.Annotations ;
2020-04-11 04:26:09 +00:00
using NzbDrone.Core.Languages ;
2020-01-07 04:31:33 +00:00
using NzbDrone.Core.Parser.Model ;
2017-01-09 13:30:15 +00:00
using NzbDrone.Core.Validation ;
namespace NzbDrone.Core.Indexers.PassThePopcorn
{
public class PassThePopcornSettingsValidator : AbstractValidator < PassThePopcornSettings >
{
public PassThePopcornSettingsValidator ( )
{
RuleFor ( c = > c . BaseUrl ) . ValidRootUrl ( ) ;
2018-12-30 13:17:26 +00:00
RuleFor ( c = > c . APIUser ) . NotEmpty ( ) ;
RuleFor ( c = > c . APIKey ) . NotEmpty ( ) ;
2019-06-14 03:54:25 +00:00
RuleFor ( c = > c . SeedCriteria ) . SetValidator ( _ = > new SeedCriteriaSettingsValidator ( ) ) ;
2017-01-09 13:30:15 +00:00
}
}
2017-06-12 12:47:05 +00:00
public class PassThePopcornSettings : ITorrentIndexerSettings
2017-01-09 13:30:15 +00:00
{
private static readonly PassThePopcornSettingsValidator Validator = new PassThePopcornSettingsValidator ( ) ;
public PassThePopcornSettings ( )
{
BaseUrl = "https://passthepopcorn.me" ;
2017-06-12 12:47:05 +00:00
MinimumSeeders = 0 ;
2019-10-14 21:47:23 +00:00
MultiLanguages = new List < int > ( ) ;
2019-10-18 03:06:01 +00:00
RequiredFlags = new List < int > ( ) ;
2017-01-09 13:30:15 +00:00
}
2017-01-30 06:48:28 +00:00
[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.")]
2017-01-09 13:30:15 +00:00
public string BaseUrl { get ; set ; }
2020-10-17 03:27:01 +00:00
[FieldDefinition(1, Label = "APIUser", HelpText = "These settings are found in your PassThePopcorn security settings (Edit Profile > Security).", Privacy = PrivacyLevel.UserName)]
2018-12-30 13:17:26 +00:00
public string APIUser { get ; set ; }
2019-12-22 21:24:11 +00:00
2020-10-17 03:27:01 +00:00
[FieldDefinition(2, Label = "APIKey", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
2018-12-30 13:17:26 +00:00
public string APIKey { 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)]
2018-08-05 14:28:05 +00:00
public IEnumerable < int > MultiLanguages { get ; set ; }
2017-01-09 13:30:15 +00:00
2019-07-15 01:18:03 +00:00
[FieldDefinition(4, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
2017-06-12 12:47:05 +00:00
public int MinimumSeeders { get ; set ; }
2018-05-27 09:05:23 +00:00
2019-07-15 01:18:03 +00:00
[FieldDefinition(5)]
2020-01-07 03:02:41 +00:00
public SeedCriteriaSettings SeedCriteria { get ; set ; } = new SeedCriteriaSettings ( ) ;
2019-06-14 03:54:25 +00:00
2020-11-12 22:54:27 +00:00
[FieldDefinition(6, Type = FieldType.TagSelect, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", HelpLink = "https://wiki.servarr.com/Definitions#Indexer_Flags", Advanced = true)]
2018-02-01 13:18:52 +00:00
public IEnumerable < int > RequiredFlags { get ; set ; }
2017-06-12 12:47:05 +00:00
2017-01-09 13:30:15 +00:00
public NzbDroneValidationResult Validate ( )
{
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
}
}
}