2018-02-01 13:18:52 +00:00
using System.Collections.Generic ;
using System.Text.RegularExpressions ;
2014-05-13 17:57:46 +00:00
using FluentValidation ;
2015-03-15 11:37:29 +00:00
using NzbDrone.Common.Extensions ;
2014-05-13 17:57:46 +00:00
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 ;
2014-05-13 17:57:46 +00:00
using NzbDrone.Core.ThingiProvider ;
using NzbDrone.Core.Validation ;
namespace NzbDrone.Core.Indexers.IPTorrents
{
public class IPTorrentsSettingsValidator : AbstractValidator < IPTorrentsSettings >
{
public IPTorrentsSettingsValidator ( )
{
2017-06-12 12:47:05 +00:00
RuleFor ( c = > c . BaseUrl ) . ValidRootUrl ( ) ;
2015-03-15 11:37:29 +00:00
2019-03-19 10:03:40 +00:00
RuleFor ( c = > c . BaseUrl ) . Matches ( @"(?:/|t\.)rss\?.+$" ) ;
2015-03-15 11:37:29 +00:00
2019-03-19 10:03:40 +00:00
RuleFor ( c = > c . BaseUrl ) . Matches ( @"(?:/|t\.)rss\?.+;download(?:;|$)" )
2016-10-10 20:42:12 +00:00
. WithMessage ( "Use Direct Download Url (;download)" )
2019-03-19 10:03:40 +00:00
. When ( v = > v . BaseUrl . IsNotNullOrWhiteSpace ( ) & & Regex . IsMatch ( v . BaseUrl , @"(?:/|t\.)rss\?.+$" ) ) ;
2014-05-13 17:57:46 +00:00
}
}
2017-06-12 12:47:05 +00:00
public class IPTorrentsSettings : ITorrentIndexerSettings
2014-05-13 17:57:46 +00:00
{
2015-03-17 04:33:34 +00:00
private static readonly IPTorrentsSettingsValidator Validator = new IPTorrentsSettingsValidator ( ) ;
2014-05-13 17:57:46 +00:00
public IPTorrentsSettings ( )
{
2017-06-12 12:47:05 +00:00
BaseUrl = string . Empty ;
MinimumSeeders = IndexerDefaults . MINIMUM_SEEDERS ;
2014-05-13 17:57:46 +00:00
}
[FieldDefinition(0, Label = "Feed URL", HelpText = "The full RSS feed url generated by IPTorrents, using only the categories you selected (HD, SD, x264, etc ...)")]
2017-06-12 12:47:05 +00:00
public string BaseUrl { get ; set ; }
2018-08-05 14:28:05 +00:00
[FieldDefinition(1, Type = FieldType.Tag, SelectOptions = typeof(Language), Label = "Multi Languages", HelpText = "What languages are normally in a multi release on this indexer?", Advanced = true)]
public IEnumerable < int > MultiLanguages { get ; set ; }
2017-06-12 12:47:05 +00:00
2018-08-05 14:28:05 +00:00
[FieldDefinition(2, Type = FieldType.Textbox, 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
2018-08-05 14:28:05 +00:00
[FieldDefinition(3, 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 ; }
2014-05-13 17:57:46 +00:00
2015-03-17 04:33:34 +00:00
public NzbDroneValidationResult Validate ( )
2014-05-13 17:57:46 +00:00
{
2015-03-17 04:33:34 +00:00
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
2014-05-13 17:57:46 +00:00
}
}
2016-10-10 20:42:12 +00:00
}