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,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Plugins.Calibre.Fixtures.Common.Models.DTO.Opf;
/// <summary>
/// Fixture class for the <see cref="OpfContributorDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal sealed class OpfContributorDtoFixture
{
/// <summary>
/// Creates an <see cref="OpfContributorDto"/>.
/// </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>
/// <returns>The created <see cref="OpfContributorDto"/>.</returns>
public OpfContributorDto Create(
string name = "Test Contributor",
string? role = null)
{
return new OpfContributorDto(name, role);
}
/// <summary>
/// Creates a list of <see cref="OpfContributorDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<OpfContributorDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Plugins.Calibre.Fixtures.Common.Models.DTO.Opf;
/// <summary>
/// Fixture class for the <see cref="OpfCreatorDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal sealed class OpfCreatorDtoFixture
{
/// <summary>
/// Creates an <see cref="OpfCreatorDto"/>.
/// </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>
/// <returns>The created <see cref="OpfCreatorDto"/>.</returns>
public OpfCreatorDto Create(
string name = "Test Creator",
string? role = null)
{
return new OpfCreatorDto(name, role);
}
/// <summary>
/// Creates a list of <see cref="OpfCreatorDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<OpfCreatorDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,81 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Plugins.Calibre.Fixtures.Common.Models.DTO.Opf;
/// <summary>
/// Fixture class for the <see cref="OpfDocumentDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
internal sealed class OpfDocumentDtoFixture
{
/// <summary>
/// Creates an <see cref="OpfDocumentDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="description">Optional. The description of the book, in HTML format.</param>
/// <param name="publisher">Optional. The publisher of the book.</param>
/// <param name="publishDate">Optional. The publication date of the book.</param>
/// <param name="languageCode">Optional. The language code of the book.</param>
/// <param name="series">Optional. The name of the series the book belongs to.</param>
/// <param name="seriesIndex">Optional. The index of the book within its series.</param>
/// <param name="rating">Optional. The personal rating of the book, on a scale of 0 to 10.</param>
/// <param name="coverHref">Optional. The href of the cover image, relative to the directory of the book.</param>
/// <param name="subjects">Optional. The subjects of the book, used as tags.</param>
/// <param name="creators">Optional. The creators of the book.</param>
/// <param name="contributors">Optional. The contributors of the book.</param>
/// <param name="identifiers">Optional. The identifiers of the book, with their schemes.</param>
/// <returns>The created <see cref="OpfDocumentDto"/>.</returns>
public OpfDocumentDto Create(
string? title = null,
string? description = null,
string? publisher = null,
DateTimeOffset? publishDate = null,
string? languageCode = null,
string? series = null,
double? seriesIndex = null,
int? rating = null,
string? coverHref = null,
IEnumerable<string>? subjects = null,
IEnumerable<OpfCreatorDto>? creators = null,
IEnumerable<OpfContributorDto>? contributors = null,
IEnumerable<OpfIdentifierDto>? identifiers = null)
{
OpfDocumentDto document = new()
{
Title = title,
Description = description,
Publisher = publisher,
PublishDate = publishDate,
LanguageCode = languageCode,
Series = series,
SeriesIndex = seriesIndex,
Rating = rating,
CoverHref = coverHref
};
if (subjects is not null)
document.Subjects.AddRange(subjects);
if (creators is not null)
document.Creators.AddRange(creators);
if (contributors is not null)
document.Contributors.AddRange(contributors);
if (identifiers is not null)
document.Identifiers.AddRange(identifiers);
return document;
}
/// <summary>
/// Creates a list of <see cref="OpfDocumentDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<OpfDocumentDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Plugins.Calibre.Fixtures.Common.Models.DTO.Opf;
/// <summary>
/// Fixture class for the <see cref="OpfIdentifierDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal sealed class OpfIdentifierDtoFixture
{
/// <summary>
/// Creates an <see cref="OpfIdentifierDto"/>.
/// </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>
/// <returns>The created <see cref="OpfIdentifierDto"/>.</returns>
public OpfIdentifierDto Create(
string scheme = "ISBN",
string value = "9780306406157")
{
return new OpfIdentifierDto(scheme, value);
}
/// <summary>
/// Creates a list of <see cref="OpfIdentifierDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<OpfIdentifierDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,13 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.Calibre.Fixtures.Core.Metadata;
/// <summary>
/// Concrete <see cref="MetadataLookupDto"/> used to represent a lookup that is not a book lookup.
/// </summary>
[ExcludeFromCodeCoverage]
internal sealed record TestMetadataLookup(Guid LibraryId, string Path) : MetadataLookupDto;
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Plugins.Calibre.Fixtures.Core.Metadata;
/// <summary>
/// Fixture class for the <see cref="TestMetadataLookup"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
internal sealed class TestMetadataLookupFixture
{
/// <summary>
/// Creates a <see cref="TestMetadataLookup"/> that is not a book lookup.
/// </summary>
/// <param name="libraryId">The Id of the media library, or <see langword="null"/> to generate a random one.</param>
/// <param name="path">The file system path of the media item.</param>
/// <returns>The created <see cref="TestMetadataLookup"/>.</returns>
public TestMetadataLookup Create(
Guid? libraryId = null,
string? path = null)
{
return new TestMetadataLookup(libraryId ?? Guid.NewGuid(), path ?? "/some/path");
}
/// <summary>
/// Creates a list of <see cref="TestMetadataLookup"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<TestMetadataLookup> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>$(SolutionDir)..\bin\api\</BaseOutputPath>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" />
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="AutoFixture.Xunit2" />
<PackageReference Include="Bogus" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\plugins\Lumina.Plugins.Calibre\Lumina.Plugins.Calibre.csproj" />
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
<ProjectReference Include="..\..\Common\Lumina.Contracts.Fixtures\Lumina.Contracts.Fixtures.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Lumina.Plugins.Calibre.Fixtures")]
[assembly: AssemblyProduct("Lumina.Plugins.Calibre.Fixtures")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("B6F9E5D2-3C4D-5E6F-9A7B-8C9D0E1F2A31")]
[assembly: InternalsVisibleTo("Lumina.Plugins.Calibre.UnitTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]