2018-11-23 07:03:32 +00:00
using System.Collections.Generic ;
2018-02-01 13:18:52 +00:00
using FluentValidation ;
2015-02-12 06:42:31 +00:00
using NzbDrone.Core.Annotations ;
using NzbDrone.Core.Validation ;
2015-05-14 20:57:45 +00:00
namespace NzbDrone.Core.Indexers.TorrentRss
2015-02-12 06:42:31 +00:00
{
public class TorrentRssIndexerSettingsValidator : AbstractValidator < TorrentRssIndexerSettings >
{
public TorrentRssIndexerSettingsValidator ( )
{
RuleFor ( c = > c . BaseUrl ) . ValidRootUrl ( ) ;
2019-06-14 03:54:25 +00:00
RuleFor ( c = > c . SeedCriteria ) . SetValidator ( _ = > new SeedCriteriaSettingsValidator ( ) ) ;
2015-02-12 06:42:31 +00:00
}
}
2017-06-12 12:47:05 +00:00
public class TorrentRssIndexerSettings : ITorrentIndexerSettings
2015-02-12 06:42:31 +00:00
{
private static readonly TorrentRssIndexerSettingsValidator validator = new TorrentRssIndexerSettingsValidator ( ) ;
public TorrentRssIndexerSettings ( )
{
BaseUrl = string . Empty ;
2015-05-14 20:57:45 +00:00
AllowZeroSize = false ;
2017-06-12 12:47:05 +00:00
MinimumSeeders = IndexerDefaults . MINIMUM_SEEDERS ;
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-02-12 06:42:31 +00:00
}
[FieldDefinition(0, Label = "Full RSS Feed URL")]
2015-05-14 20:57:45 +00:00
public string BaseUrl { get ; set ; }
[FieldDefinition(1, Label = "Cookie", HelpText = "If you site requires a login cookie to access the rss, you'll have to retrieve it via a browser.")]
public string Cookie { get ; set ; }
[FieldDefinition(2, Type = FieldType.Checkbox, Label = "Allow Zero Size", HelpText="Enabling this will allow you to use feeds that don't specify release size, but be careful, size related checks will not be performed.")]
public bool AllowZeroSize { 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-02-12 06:42:31 +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-06-14 03:54:25 +00:00
[FieldDefinition(5)]
public SeedCriteriaSettings SeedCriteria { get ; } = new SeedCriteriaSettings ( ) ;
2019-10-18 03:06:01 +00:00
// [FieldDefinition(6, 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
2015-02-12 06:42:31 +00:00
public NzbDroneValidationResult Validate ( )
{
return new NzbDroneValidationResult ( validator . Validate ( this ) ) ;
}
}
2018-05-27 09:05:23 +00:00
}