2020-01-25 22:49:40 +00:00
using System.Collections.Generic ;
using FluentValidation ;
using NzbDrone.Core.Annotations ;
2020-04-11 04:26:09 +00:00
using NzbDrone.Core.Languages ;
2020-01-25 22:49:40 +00:00
using NzbDrone.Core.Parser.Model ;
using NzbDrone.Core.Validation ;
namespace NzbDrone.Core.Indexers.FileList
{
public class FileListSettingsValidator : AbstractValidator < FileListSettings >
{
public FileListSettingsValidator ( )
{
RuleFor ( c = > c . BaseUrl ) . ValidRootUrl ( ) ;
RuleFor ( c = > c . Username ) . NotEmpty ( ) ;
RuleFor ( c = > c . Passkey ) . NotEmpty ( ) ;
RuleFor ( c = > c . SeedCriteria ) . SetValidator ( _ = > new SeedCriteriaSettingsValidator ( ) ) ;
}
}
public class FileListSettings : ITorrentIndexerSettings
{
private static readonly FileListSettingsValidator Validator = new FileListSettingsValidator ( ) ;
public FileListSettings ( )
{
2020-10-04 05:17:26 +00:00
BaseUrl = "https://filelist.io" ;
2020-01-25 22:49:40 +00:00
MinimumSeeders = IndexerDefaults . MINIMUM_SEEDERS ;
2020-10-07 03:03:29 +00:00
Categories = new int [ ]
{
( int ) FileListCategories . Movie_HD ,
( int ) FileListCategories . Movie_SD ,
( int ) FileListCategories . Movie_4K
} ;
2020-01-25 22:49:40 +00:00
MultiLanguages = new List < int > ( ) ;
RequiredFlags = new List < int > ( ) ;
}
[FieldDefinition(0, Label = "Username")]
public string Username { get ; set ; }
[FieldDefinition(1, Label = "Passkey")]
public string Passkey { get ; set ; }
2020-04-11 04:26:09 +00:00
[FieldDefinition(2, Type = FieldType.TagSelect, SelectOptions = typeof(LanguageFieldConverter), Label = "Multi Languages", HelpText = "What languages are normally in a multi release on this indexer?", Advanced = true)]
2020-01-25 22:49:40 +00:00
public IEnumerable < int > MultiLanguages { get ; set ; }
[FieldDefinition(3, Label = "API URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your API key will be sent to that host.")]
public string BaseUrl { get ; set ; }
2020-10-07 03:03:29 +00:00
[FieldDefinition(4, Label = "Categories", Type = FieldType.Select, SelectOptions = typeof(FileListCategories), Advanced = true, HelpText = "Categories for use in search and feeds. If unspecified, all options are used.")]
2020-01-25 22:49:40 +00:00
public IEnumerable < int > Categories { get ; set ; }
[FieldDefinition(5, Type = FieldType.Number, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get ; set ; }
[FieldDefinition(6, Type = FieldType.TagSelect, 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)]
public IEnumerable < int > RequiredFlags { get ; set ; }
[FieldDefinition(7)]
public SeedCriteriaSettings SeedCriteria { get ; set ; } = new SeedCriteriaSettings ( ) ;
public NzbDroneValidationResult Validate ( )
{
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
}
}
public enum FileListCategories
{
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_SD = 1 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_DVD = 2 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_DVDRO = 3 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_HD = 4 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_HDRO = 19 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_BluRay = 20 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_BluRay4K = 26 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_3D = 25 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Movie_4K = 6 ,
2020-10-07 03:03:29 +00:00
[FieldOption]
2020-01-25 22:49:40 +00:00
Xxx = 7
}
}