mirror of
https://github.com/Radarr/Radarr.git
synced 2024-10-05 15:47:20 +02:00
Simplify calibre settings
The IProviderConfig stuff wasn't used
This commit is contained in:
parent
d2dcc45492
commit
655017e1ed
@ -2,8 +2,7 @@
|
||||
using System.Linq;
|
||||
using FluentValidation;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Books.Calibre
|
||||
@ -23,7 +22,7 @@ public CalibreSettingsValidator()
|
||||
}
|
||||
}
|
||||
|
||||
public class CalibreSettings : IProviderConfig
|
||||
public class CalibreSettings : IEmbeddedDocument
|
||||
{
|
||||
private static readonly CalibreSettingsValidator Validator = new CalibreSettingsValidator();
|
||||
|
||||
@ -32,28 +31,13 @@ public CalibreSettings()
|
||||
Port = 8080;
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
|
||||
public string Host { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Port", Type = FieldType.Textbox)]
|
||||
public int Port { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Url Base", Type = FieldType.Textbox, Advanced = true, HelpText = "Adds a prefix to the calibre url, e.g. http://[host]:[port]/[urlBase]")]
|
||||
public int Port { get; set; } = 8080;
|
||||
public string UrlBase { get; set; }
|
||||
|
||||
[FieldDefinition(3, Label = "Username", Type = FieldType.Textbox)]
|
||||
public string Username { get; set; }
|
||||
|
||||
[FieldDefinition(4, Label = "Password", Type = FieldType.Password)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[FieldDefinition(5, Label = "Convert to Format", Type = FieldType.Textbox, HelpText = "Optionally ask calibre to convert to other formats on import. Comma separated list.")]
|
||||
public string OutputFormat { get; set; }
|
||||
|
||||
[FieldDefinition(6, Label = "Conversion Profile", Type = FieldType.Select, SelectOptions = typeof(CalibreProfile), HelpText = "The output profile to use for conversion")]
|
||||
public int OutputProfile { get; set; }
|
||||
|
||||
[FieldDefinition(9, Label = "Use SSL", Type = FieldType.Checkbox)]
|
||||
public bool UseSsl { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
|
@ -1,9 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Dapper;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Books.Calibre;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
namespace NzbDrone.Core.RootFolders
|
||||
@ -21,37 +16,6 @@ public RootFolderRepository(IMainDatabase database, IEventAggregator eventAggreg
|
||||
|
||||
protected override bool PublishModelEvents => true;
|
||||
|
||||
protected override List<RootFolder> Query(SqlBuilder builder)
|
||||
{
|
||||
var type = typeof(RootFolder);
|
||||
var sql = builder.Select(type).AddSelectTemplate(type);
|
||||
|
||||
var results = new List<RootFolder>();
|
||||
|
||||
using (var conn = _database.OpenConnection())
|
||||
using (var reader = conn.ExecuteReader(sql.RawSql, sql.Parameters))
|
||||
{
|
||||
var parser = reader.GetRowParser<RootFolder>(type);
|
||||
var settingsIndex = reader.GetOrdinal(nameof(RootFolder.CalibreSettings));
|
||||
var serializerSettings = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
var body = reader.IsDBNull(settingsIndex) ? null : reader.GetString(settingsIndex);
|
||||
var item = parser(reader);
|
||||
|
||||
if (body.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
item.CalibreSettings = JsonSerializer.Deserialize<CalibreSettings>(body, serializerSettings);
|
||||
}
|
||||
|
||||
results.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public new void Delete(int id)
|
||||
{
|
||||
var model = Get(id);
|
||||
|
Loading…
Reference in New Issue
Block a user