2023-12-04 10:53:33 +00:00
|
|
|
using System;
|
2018-02-01 13:18:52 +00:00
|
|
|
using System.Collections.Generic;
|
2017-01-05 16:12:46 +00:00
|
|
|
using FluentValidation;
|
|
|
|
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;
|
2017-01-05 16:12:46 +00:00
|
|
|
using NzbDrone.Core.Validation;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.TorrentPotato
|
|
|
|
{
|
|
|
|
public class TorrentPotatoSettingsValidator : AbstractValidator<TorrentPotatoSettings>
|
|
|
|
{
|
|
|
|
public TorrentPotatoSettingsValidator()
|
|
|
|
{
|
|
|
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
2019-06-14 03:54:25 +00:00
|
|
|
|
|
|
|
RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator());
|
2017-01-05 16:12:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-12 12:47:05 +00:00
|
|
|
public class TorrentPotatoSettings : ITorrentIndexerSettings
|
2017-01-05 16:12:46 +00:00
|
|
|
{
|
|
|
|
private static readonly TorrentPotatoSettingsValidator Validator = new TorrentPotatoSettingsValidator();
|
|
|
|
|
|
|
|
public TorrentPotatoSettings()
|
|
|
|
{
|
2017-01-13 21:12:49 +00:00
|
|
|
BaseUrl = "http://127.0.0.1";
|
2017-06-12 12:47:05 +00:00
|
|
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
2023-12-04 10:53:33 +00:00
|
|
|
MultiLanguages = Array.Empty<int>();
|
|
|
|
RequiredFlags = Array.Empty<int>();
|
2017-01-05 16:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[FieldDefinition(0, Label = "API URL", HelpText = "URL to TorrentPotato api.")]
|
|
|
|
public string BaseUrl { get; set; }
|
2019-12-22 21:24:11 +00:00
|
|
|
|
2020-10-17 03:27:01 +00:00
|
|
|
[FieldDefinition(1, Label = "Username", HelpText = "The username you use at your indexer.", Privacy = PrivacyLevel.UserName)]
|
2017-01-05 16:12:46 +00:00
|
|
|
public string User { get; set; }
|
|
|
|
|
2020-10-17 03:27:01 +00:00
|
|
|
[FieldDefinition(2, Label = "Passkey", HelpText = "The password you use at your Indexer.", Privacy = PrivacyLevel.Password)]
|
2017-01-05 16:12:46 +00:00
|
|
|
public string Passkey { get; set; }
|
2019-12-22 21:24:11 +00:00
|
|
|
|
2024-04-16 03:24:05 +00:00
|
|
|
[FieldDefinition(3, 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; }
|
2019-06-14 03:54:25 +00:00
|
|
|
|
2024-04-16 03:24:05 +00:00
|
|
|
[FieldDefinition(4)]
|
2020-01-07 03:02:41 +00:00
|
|
|
public SeedCriteriaSettings SeedCriteria { get; set; } = new SeedCriteriaSettings();
|
2019-06-14 03:54:25 +00:00
|
|
|
|
2024-04-16 03:24:05 +00:00
|
|
|
[FieldDefinition(5, Type = FieldType.Checkbox, Label = "IndexerSettingsRejectBlocklistedTorrentHashes", HelpText = "IndexerSettingsRejectBlocklistedTorrentHashesHelpText", Advanced = true)]
|
2023-10-29 18:23:23 +00:00
|
|
|
public bool RejectBlocklistedTorrentHashesWhileGrabbing { get; set; }
|
2017-06-12 12:47:05 +00:00
|
|
|
|
2024-04-16 03:24:05 +00:00
|
|
|
[FieldDefinition(6, Type = FieldType.Select, SelectOptions = typeof(RealLanguageFieldConverter), Label = "IndexerSettingsMultiLanguageRelease", HelpText = "IndexerSettingsMultiLanguageReleaseHelpText", Advanced = true)]
|
|
|
|
public IEnumerable<int> MultiLanguages { get; set; }
|
|
|
|
|
|
|
|
[FieldDefinition(7, Type = FieldType.Select, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", Advanced = true)]
|
|
|
|
public IEnumerable<int> RequiredFlags { get; set; }
|
|
|
|
|
2017-01-05 16:12:46 +00:00
|
|
|
public NzbDroneValidationResult Validate()
|
|
|
|
{
|
|
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
|
|
}
|
|
|
|
}
|
2017-03-11 13:52:34 +00:00
|
|
|
}
|