mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
Simplify calibre settings
The IProviderConfig stuff wasn't used
This commit is contained in:
@@ -2,8 +2,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Books.Calibre
|
namespace NzbDrone.Core.Books.Calibre
|
||||||
@@ -23,7 +22,7 @@ namespace NzbDrone.Core.Books.Calibre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CalibreSettings : IProviderConfig
|
public class CalibreSettings : IEmbeddedDocument
|
||||||
{
|
{
|
||||||
private static readonly CalibreSettingsValidator Validator = new CalibreSettingsValidator();
|
private static readonly CalibreSettingsValidator Validator = new CalibreSettingsValidator();
|
||||||
|
|
||||||
@@ -32,28 +31,13 @@ namespace NzbDrone.Core.Books.Calibre
|
|||||||
Port = 8080;
|
Port = 8080;
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
|
|
||||||
public string Host { get; set; }
|
public string Host { get; set; }
|
||||||
|
public int Port { get; set; } = 8080;
|
||||||
[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 string UrlBase { get; set; }
|
public string UrlBase { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(3, Label = "Username", Type = FieldType.Textbox)]
|
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(4, Label = "Password", Type = FieldType.Password)]
|
|
||||||
public string Password { get; set; }
|
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; }
|
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; }
|
public int OutputProfile { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(9, Label = "Use SSL", Type = FieldType.Checkbox)]
|
|
||||||
public bool UseSsl { get; set; }
|
public bool UseSsl { get; set; }
|
||||||
|
|
||||||
public NzbDroneValidationResult Validate()
|
public NzbDroneValidationResult Validate()
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using NzbDrone.Core.Datastore;
|
||||||
using System.Text.Json;
|
|
||||||
using Dapper;
|
|
||||||
using NzbDrone.Common.Extensions;
|
|
||||||
using NzbDrone.Core.Books.Calibre;
|
|
||||||
using NzbDrone.Core.Datastore;
|
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
|
||||||
namespace NzbDrone.Core.RootFolders
|
namespace NzbDrone.Core.RootFolders
|
||||||
@@ -21,37 +16,6 @@ namespace NzbDrone.Core.RootFolders
|
|||||||
|
|
||||||
protected override bool PublishModelEvents => true;
|
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)
|
public new void Delete(int id)
|
||||||
{
|
{
|
||||||
var model = Get(id);
|
var model = Get(id);
|
||||||
|
|||||||
Reference in New Issue
Block a user