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 ;
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 ;
2015-02-12 06:42:31 +00:00
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
{
2019-12-22 22:08:53 +00:00
private static readonly TorrentRssIndexerSettingsValidator Validator = new TorrentRssIndexerSettingsValidator ( ) ;
2015-02-12 06:42:31 +00:00
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 ; }
2019-12-22 22:08:53 +00:00
[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.")]
2015-05-14 20:57:45 +00:00
public bool AllowZeroSize { 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 ; }
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)]
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
2015-02-12 06:42:31 +00:00
public NzbDroneValidationResult Validate ( )
{
2019-12-22 22:08:53 +00:00
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
2015-02-12 06:42:31 +00:00
}
}
2018-05-27 09:05:23 +00:00
}