Adds artwork provider system and Calibre plugin

This commit is contained in:
BinaryAlley committed 2026-08-24 14:18:14 -07:00
1 parent c82fadc7a2
commit 6693ff3f60
124 files changed
+9715 -74

No files matched your search

@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Calibre.Core;
using Lumina.Plugins.Contracts.Core.Metadata;
using Microsoft.Extensions.DependencyInjection;
using System;
#endregion
namespace Lumina.Plugins.Calibre.Common.DependencyInjection;
/// <summary>
/// Provides extension methods for registering the Calibre metadata and artwork providers.
/// </summary>
internal static class CalibreServices
{
/// <summary>
/// Registers the Calibre book metadata provider, associated with the plugin that provides it.
/// </summary>
/// <param name="services">The service collection to register the services into.</param>
/// <param name="pluginId">The unique identifier of the plugin that provides the metadata.</param>
/// <returns>The service collection, for chaining.</returns>
internal static IServiceCollection AddCalibreBookMetadataProvider(this IServiceCollection services, Guid pluginId)
{
ArgumentNullException.ThrowIfNull(services);
// Register the metadata provider as a keyed by pluginId transient service, so it can be resolved specifically among other IMetadataProvider implementations.
services.AddKeyedTransient<IMetadataProvider, CalibreBookMetadataProvider>(pluginId);
return services;
}
/// <summary>
/// Registers the Calibre artwork provider, associated with the plugin that provides it.
/// </summary>
/// <param name="services">The service collection to register the services into.</param>
/// <param name="pluginId">The unique identifier of the plugin that provides the artwork.</param>
/// <returns>The service collection, for chaining.</returns>
internal static IServiceCollection AddCalibreArtworkProvider(this IServiceCollection services, Guid pluginId)
{
ArgumentNullException.ThrowIfNull(services);
// Register the artwork provider as a keyed by pluginId transient service, so it can be resolved specifically among other IArtworkProvider implementations.
services.AddKeyedTransient<IArtworkProvider, CalibreArtworkProvider>(pluginId);
return services;
}
}
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
/// <summary>
/// Data transfer object for a contributor of a book read from an OPF file.
/// </summary>
/// <param name="Name">The name of the contributor.</param>
/// <param name="Role">The role code of the contributor, for example <c>bkp</c> for the book producer.</param>
[DebuggerDisplay("Name: {Name}")]
internal sealed record OpfContributorDto(
string Name,
string? Role
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
/// <summary>
/// Data transfer object for a creator of a book read from an OPF file.
/// </summary>
/// <param name="Name">The name of the creator.</param>
/// <param name="Role">The role code of the creator, for example <c>aut</c> for author.</param>
[DebuggerDisplay("Name: {Name}")]
internal sealed record OpfCreatorDto(
string Name,
string? Role
);
@@ -0,0 +1,79 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
/// <summary>
/// Data transfer object for the metadata read from a Calibre OPF file.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
internal sealed class OpfDocumentDto
{
/// <summary>
/// Gets or sets the title of the book.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the description of the book, in HTML format.
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Gets or sets the publisher of the book.
/// </summary>
public string? Publisher { get; set; }
/// <summary>
/// Gets or sets the publication date of the book.
/// </summary>
public DateTimeOffset? PublishDate { get; set; }
/// <summary>
/// Gets or sets the language code of the book.
/// </summary>
public string? LanguageCode { get; set; }
/// <summary>
/// Gets or sets the name of the series the book belongs to, if applicable.
/// </summary>
public string? Series { get; set; }
/// <summary>
/// Gets or sets the index of the book within its series, if applicable.
/// </summary>
public double? SeriesIndex { get; set; }
/// <summary>
/// Gets or sets the personal rating of the book, on a scale of 0 to 10.
/// </summary>
public int? Rating { get; set; }
/// <summary>
/// Gets or sets the href of the cover image, relative to the directory of the book.
/// </summary>
public string? CoverHref { get; set; }
/// <summary>
/// Gets the creators of the book.
/// </summary>
public List<OpfCreatorDto> Creators { get; } = [];
/// <summary>
/// Gets the contributors of the book.
/// </summary>
public List<OpfContributorDto> Contributors { get; } = [];
/// <summary>
/// Gets the identifiers of the book, with their schemes.
/// </summary>
public List<OpfIdentifierDto> Identifiers { get; } = [];
/// <summary>
/// Gets the subjects of the book, used as tags.
/// </summary>
public List<string> Subjects { get; } = [];
}
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
/// <summary>
/// Data transfer object for an identifier of a book read from an OPF file, with its scheme.
/// </summary>
/// <param name="Scheme">The scheme of the identifier, for example <c>ISBN</c> or <c>GOODREADS</c>.</param>
/// <param name="Value">The value of the identifier.</param>
[DebuggerDisplay("{Scheme}: {Value}")]
internal sealed record OpfIdentifierDto(
string Scheme,
string Value
);