2015-12-20 01:18:22 +00:00
using System.ComponentModel ;
using FluentValidation ;
using Newtonsoft.Json ;
2014-05-13 17:57:46 +00:00
using NzbDrone.Core.Annotations ;
using NzbDrone.Core.ThingiProvider ;
2015-03-17 04:33:34 +00:00
using NzbDrone.Core.Validation ;
2014-05-13 17:57:46 +00:00
using NzbDrone.Core.Validation.Paths ;
2016-02-14 16:55:32 +00:00
namespace NzbDrone.Core.Download.Clients.Blackhole
2014-05-13 17:57:46 +00:00
{
public class TorrentBlackholeSettingsValidator : AbstractValidator < TorrentBlackholeSettings >
{
public TorrentBlackholeSettingsValidator ( )
{
2022-11-20 18:27:45 +00:00
// Todo: Validate that the path actually exists
2014-05-13 17:57:46 +00:00
RuleFor ( c = > c . TorrentFolder ) . IsValidPath ( ) ;
2019-06-14 03:54:25 +00:00
RuleFor ( c = > c . MagnetFileExtension ) . NotEmpty ( ) ;
2014-05-13 17:57:46 +00:00
}
}
public class TorrentBlackholeSettings : IProviderConfig
{
2015-12-20 01:18:22 +00:00
public TorrentBlackholeSettings ( )
{
2019-06-14 03:54:25 +00:00
MagnetFileExtension = ".magnet" ;
2015-12-20 01:18:22 +00:00
ReadOnly = true ;
}
2015-03-17 04:33:34 +00:00
private static readonly TorrentBlackholeSettingsValidator Validator = new TorrentBlackholeSettingsValidator ( ) ;
2014-05-13 17:57:46 +00:00
2017-01-12 02:59:13 +00:00
[FieldDefinition(0, Label = "Torrent Folder", Type = FieldType.Path, HelpText = "Folder in which Radarr will store the .torrent file")]
2015-10-03 17:45:26 +00:00
public string TorrentFolder { get ; set ; }
2014-05-13 17:57:46 +00:00
2017-01-12 02:59:13 +00:00
[FieldDefinition(1, Label = "Watch Folder", Type = FieldType.Path, HelpText = "Folder from which Radarr should import completed downloads")]
2015-10-03 17:45:26 +00:00
public string WatchFolder { get ; set ; }
2014-05-13 17:57:46 +00:00
2015-12-20 01:18:22 +00:00
[DefaultValue(false)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
2016-08-05 21:09:45 +00:00
[FieldDefinition(2, Label = "Save Magnet Files", Type = FieldType.Checkbox, HelpText = "Save a .magnet file with the magnet link if no .torrent file is available (only useful if the download client supports .magnet files)")]
public bool SaveMagnetFiles { get ; set ; }
2019-06-14 03:54:25 +00:00
[FieldDefinition(3, Label = "Save Magnet Files", Type = FieldType.Textbox, HelpText = "Extension to use for magnet links, defaults to '.magnet'")]
public string MagnetFileExtension { get ; set ; }
2016-08-05 21:09:45 +00:00
[DefaultValue(false)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
2019-06-14 03:54:25 +00:00
[FieldDefinition(4, Label = "Read Only", Type = FieldType.Checkbox, HelpText = "Instead of moving files this will instruct Radarr to Copy or Hardlink (depending on settings/system configuration)")]
2015-12-20 01:18:22 +00:00
public bool ReadOnly { 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
}
}
}