2018-02-01 13:18:52 +00:00
using System.Collections.Generic ;
2019-06-14 03:54:25 +00:00
using System.Linq ;
2017-01-05 16:12:46 +00:00
using FluentValidation ;
using NzbDrone.Core.Annotations ;
2018-08-05 14:28:05 +00:00
using NzbDrone.Core.Parser ;
2018-02-01 13:18:52 +00:00
using NzbDrone.Core.Parser.Model ;
2017-01-05 16:12:46 +00:00
using NzbDrone.Core.ThingiProvider ;
using NzbDrone.Core.Validation ;
namespace NzbDrone.Core.Indexers.TorrentPotato
{
public class TorrentPotatoSettingsValidator : AbstractValidator < TorrentPotatoSettings >
{
public TorrentPotatoSettingsValidator ( )
{
RuleFor ( c = > c . BaseUrl ) . ValidRootUrl ( ) ;
2019-06-14 03:54:25 +00:00
RuleFor ( c = > c . SeedCriteria ) . SetValidator ( _ = > new SeedCriteriaSettingsValidator ( ) ) ;
2017-01-05 16:12:46 +00:00
}
}
2017-06-12 12:47:05 +00:00
public class TorrentPotatoSettings : ITorrentIndexerSettings
2017-01-05 16:12:46 +00:00
{
private static readonly TorrentPotatoSettingsValidator Validator = new TorrentPotatoSettingsValidator ( ) ;
public TorrentPotatoSettings ( )
{
2017-01-13 21:12:49 +00:00
BaseUrl = "http://127.0.0.1" ;
2017-06-12 12:47:05 +00:00
MinimumSeeders = IndexerDefaults . MINIMUM_SEEDERS ;
2019-10-14 21:47:23 +00:00
MultiLanguages = new List < int > ( ) ;
2017-01-05 16:12:46 +00:00
}
[FieldDefinition(0, Label = "API URL", HelpText = "URL to TorrentPotato api.")]
public string BaseUrl { get ; set ; }
[FieldDefinition(1, Label = "Username", HelpText = "The username you use at your indexer.")]
public string User { get ; set ; }
2017-05-23 15:30:59 +00:00
[FieldDefinition(2, Label = "Passkey", HelpText = "The password you use at your Indexer.")]
2017-01-05 16:12:46 +00:00
public string Passkey { get ; set ; }
2018-08-05 14:28:05 +00:00
2019-06-14 03:54:25 +00:00
// [FieldDefinition(3, Type = FieldType.Tag, SelectOptions = typeof(Language), 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-06-12 12:47:05 +00:00
2018-11-23 07:03:32 +00:00
[FieldDefinition(4, Type = FieldType.Number, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
2017-06-12 12:47:05 +00:00
public int MinimumSeeders { get ; set ; }
2019-06-14 03:54:25 +00:00
[FieldDefinition(5)]
public SeedCriteriaSettings SeedCriteria { get ; } = new SeedCriteriaSettings ( ) ;
[FieldDefinition(6, Type = FieldType.Tag, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", 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-05 16:12:46 +00:00
public NzbDroneValidationResult Validate ( )
{
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
}
}
2017-03-11 13:52:34 +00:00
}