2018-11-23 07:03:32 +00:00
using System.Collections.Generic ;
2018-02-01 13:18:52 +00:00
using FluentValidation ;
2015-05-24 18:41:12 +00:00
using NzbDrone.Core.Annotations ;
using NzbDrone.Core.Validation ;
namespace NzbDrone.Core.Indexers.Rarbg
{
public class RarbgSettingsValidator : AbstractValidator < RarbgSettings >
{
public RarbgSettingsValidator ( )
{
RuleFor ( c = > c . BaseUrl ) . ValidRootUrl ( ) ;
2019-06-14 03:54:25 +00:00
2019-07-05 20:01:07 +00:00
RuleFor ( c = > c . Categories ) . NotEmpty ( ) ;
2019-06-14 03:54:25 +00:00
RuleFor ( c = > c . SeedCriteria ) . SetValidator ( _ = > new SeedCriteriaSettingsValidator ( ) ) ;
2015-05-24 18:41:12 +00:00
}
}
2017-06-12 12:47:05 +00:00
public class RarbgSettings : ITorrentIndexerSettings
2015-05-24 18:41:12 +00:00
{
private static readonly RarbgSettingsValidator Validator = new RarbgSettingsValidator ( ) ;
public RarbgSettings ( )
{
BaseUrl = "https://torrentapi.org" ;
RankedOnly = false ;
2017-06-12 12:47:05 +00:00
MinimumSeeders = IndexerDefaults . MINIMUM_SEEDERS ;
2019-07-05 20:01:07 +00:00
Categories = new [ ] { 14 , 48 , 17 , 44 , 45 , 47 , 50 , 51 , 52 , 42 , 46 } ;
2019-10-14 21:47:23 +00:00
MultiLanguages = new List < int > ( ) ;
2019-10-18 03:06:01 +00:00
RequiredFlags = new List < int > ( ) ;
2015-05-24 18:41:12 +00:00
}
[FieldDefinition(0, Label = "API URL", HelpText = "URL to Rarbg api, not the website.")]
public string BaseUrl { get ; set ; }
2015-06-05 21:31:51 +00:00
[FieldDefinition(1, Type = FieldType.Checkbox, Label = "Ranked Only", HelpText = "Only include ranked results.")]
2015-05-24 18:41:12 +00:00
public bool RankedOnly { get ; set ; }
2018-05-27 09:05:23 +00:00
2016-08-10 18:45:48 +00:00
[FieldDefinition(2, Type = FieldType.Captcha, Label = "CAPTCHA Token", HelpText = "CAPTCHA Clearance token used to handle CloudFlare Anti-DDOS measures on shared-ip VPNs.")]
public string CaptchaToken { 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 ; }
2015-05-24 18:41:12 +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 ; }
2018-05-27 09:05:23 +00:00
2019-10-18 03:06:01 +00:00
// [FieldDefinition(5, Type = FieldType.Tag, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", HelpLink = "https://github.com/Radarr/Radarr/wiki/Indexer-Flags#1-required-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
2019-07-05 20:01:07 +00:00
[FieldDefinition(6, Type = FieldType.Textbox, Label = "Categories", HelpText = "Comma Separated list, you can retrieve the ID by checking the URL behind the category on the website (i.e. Movie/x264/1080 = 44)", HelpLink = "https://rarbgmirror.org/torrents.php?category=movies", Advanced = true)]
public IEnumerable < int > Categories { get ; set ; }
[FieldDefinition(7)]
2019-06-14 03:54:25 +00:00
public SeedCriteriaSettings SeedCriteria { get ; } = new SeedCriteriaSettings ( ) ;
2015-05-24 18:41:12 +00:00
public NzbDroneValidationResult Validate ( )
{
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
}
}
2018-05-27 09:05:23 +00:00
}