2024-04-16 03:24:05 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2021-08-04 04:00:28 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2024-04-14 04:16:26 +00:00
|
|
|
using Equ;
|
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;
|
2024-04-16 03:24:05 +00:00
|
|
|
using NzbDrone.Core.Languages;
|
2014-05-13 17:57:46 +00:00
|
|
|
using NzbDrone.Core.Validation;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.IPTorrents
|
|
|
|
{
|
|
|
|
public class IPTorrentsSettingsValidator : AbstractValidator<IPTorrentsSettings>
|
|
|
|
{
|
|
|
|
public IPTorrentsSettingsValidator()
|
|
|
|
{
|
2017-05-06 19:50:33 +00:00
|
|
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
2015-03-15 11:37:29 +00:00
|
|
|
|
2018-12-17 02:46:09 +00:00
|
|
|
RuleFor(c => c.BaseUrl).Matches(@"(?:/|t\.)rss\?.+$");
|
2015-03-15 11:37:29 +00:00
|
|
|
|
2018-12-17 02:46:09 +00:00
|
|
|
RuleFor(c => c.BaseUrl).Matches(@"(?:/|t\.)rss\?.+;download(?:;|$)")
|
2016-10-10 20:42:12 +00:00
|
|
|
.WithMessage("Use Direct Download Url (;download)")
|
2018-12-17 02:46:09 +00:00
|
|
|
.When(v => v.BaseUrl.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.BaseUrl, @"(?:/|t\.)rss\?.+$"));
|
2018-05-03 19:39:56 +00:00
|
|
|
|
|
|
|
RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator());
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-14 04:16:26 +00:00
|
|
|
public class IPTorrentsSettings : PropertywiseEquatable<IPTorrentsSettings>, ITorrentIndexerSettings
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2024-04-14 04:16:26 +00:00
|
|
|
private static readonly IPTorrentsSettingsValidator Validator = new ();
|
2014-05-13 17:57:46 +00:00
|
|
|
|
|
|
|
public IPTorrentsSettings()
|
|
|
|
{
|
2017-03-15 03:29:04 +00:00
|
|
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
2024-04-16 03:24:05 +00:00
|
|
|
MultiLanguages = Array.Empty<int>();
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2023-11-17 00:30:22 +00:00
|
|
|
[FieldDefinition(0, Label = "IndexerIPTorrentsSettingsFeedUrl", HelpText = "IndexerIPTorrentsSettingsFeedUrlHelpText")]
|
2017-05-06 19:50:33 +00:00
|
|
|
public string BaseUrl { get; set; }
|
2014-05-13 17:57:46 +00:00
|
|
|
|
2023-11-17 00:30:22 +00:00
|
|
|
[FieldDefinition(1, Type = FieldType.Number, Label = "IndexerSettingsMinimumSeeders", HelpText = "IndexerSettingsMinimumSeedersHelpText", Advanced = true)]
|
2017-03-15 03:29:04 +00:00
|
|
|
public int MinimumSeeders { get; set; }
|
|
|
|
|
2018-05-03 19:39:56 +00:00
|
|
|
[FieldDefinition(2)]
|
2024-04-14 04:16:26 +00:00
|
|
|
public SeedCriteriaSettings SeedCriteria { get; set; } = new ();
|
2017-11-05 17:17:05 +00:00
|
|
|
|
2024-01-16 05:52:55 +00:00
|
|
|
[FieldDefinition(3, Type = FieldType.Checkbox, Label = "IndexerSettingsRejectBlocklistedTorrentHashes", HelpText = "IndexerSettingsRejectBlocklistedTorrentHashesHelpText", Advanced = true)]
|
2023-10-29 18:23:23 +00:00
|
|
|
public bool RejectBlocklistedTorrentHashesWhileGrabbing { get; set; }
|
|
|
|
|
2024-04-16 03:24:05 +00:00
|
|
|
[FieldDefinition(4, Type = FieldType.Select, SelectOptions = typeof(RealLanguageFieldConverter), Label = "IndexerSettingsMultiLanguageRelease", HelpText = "IndexerSettingsMultiLanguageReleaseHelpText", Advanced = true)]
|
|
|
|
public IEnumerable<int> MultiLanguages { get; set; }
|
|
|
|
|
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
|
|
|
}
|