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

@@ -1,11 +1,11 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -66,7 +66,7 @@ public sealed class Book : AggregateRoot<BookId>
/// <summary>
/// Gets the volume or book number in the series, if applicable.
/// </summary>
public Optional<int> VolumeNumber { get; private set; }
public Optional<float> VolumeNumber { get; private set; }
/// <summary>
/// Gets the series name, if the book is part of a series.
@@ -118,6 +118,11 @@ public sealed class Book : AggregateRoot<BookId>
/// </summary>
public Optional<string> AppleBooksId { get; private set; }
/// <summary>
/// Gets the file system path of the cover image of the book, if applicable.
/// </summary>
public Optional<string> CoverImagePath { get; private set; }
/// <summary>
/// Gets the list of ISBN (International Standard Book Number) of the book.
/// </summary>
@@ -165,7 +170,7 @@ public sealed class Book : AggregateRoot<BookId>
WrittenContentMetadata metadata,
Optional<BookFormat> format,
Optional<string> edition,
Optional<int> volumeNumber,
Optional<float> volumeNumber,
Optional<BookSeries> series,
Optional<string> asin,
Optional<string> goodreadsId,
@@ -202,6 +207,7 @@ public sealed class Book : AggregateRoot<BookId>
GoogleBooksId = googleBooksId;
BarnesAndNobleId = barnesAndNobleId;
AppleBooksId = appleBooksId;
CoverImagePath = Optional<string>.None();
CreatedOnUtc = createdOnUtc;
UpdatedOnUtc = updatedOnUtc.HasValue ? updatedOnUtc.Value : null;
_isbns = isbns;
@@ -240,7 +246,7 @@ public sealed class Book : AggregateRoot<BookId>
WrittenContentMetadata metadata,
Optional<BookFormat> format,
Optional<string> edition,
Optional<int> volumeNumber,
Optional<float> volumeNumber,
Optional<BookSeries> series,
Optional<string> asin,
Optional<string> goodreadsId,
@@ -317,7 +323,7 @@ public sealed class Book : AggregateRoot<BookId>
WrittenContentMetadata metadata,
Optional<BookFormat> format,
Optional<string> edition,
Optional<int> volumeNumber,
Optional<float> volumeNumber,
Optional<BookSeries> series,
Optional<string> asin,
Optional<string> goodreadsId,
@@ -381,6 +387,15 @@ public sealed class Book : AggregateRoot<BookId>
MetadataStatus = MetadataStatus.Failed;
}
/// <summary>
/// Sets the file system path of the cover image of the book.
/// </summary>
/// <param name="coverImagePath">The file system path of the cover image of the book.</param>
public void SetBookCoverImagePath(string coverImagePath)
{
CoverImagePath = coverImagePath;
}
/// <summary>
/// Applies the enriched <paramref name="metadata"/> and the related fields to the book, marking its metadata as enriched by the provided <paramref name="providerName"/>.
/// </summary>
@@ -406,7 +421,7 @@ public sealed class Book : AggregateRoot<BookId>
WrittenContentMetadata metadata,
Optional<BookFormat> format,
Optional<string> edition,
Optional<int> volumeNumber,
Optional<float> volumeNumber,
Optional<BookSeries> series,
Optional<string> asin,
Optional<string> goodreadsId,
@@ -33,9 +33,8 @@ internal class BookLibraryTypeScanner : IBookLibraryTypeScanner
/// Creates the media library scan jobs for the provided media library.
/// </summary>
/// <param name="libraryId">The unique identifier of the media library for which to create the media library scan jobs.</param>
/// <param name="downloadMetadataFromWeb">Whether the library permits downloading data from the web, or not.</param>
/// <returns>A collection of media library scan jobs.</returns>
public IEnumerable<IMediaLibraryScanJob> CreateScanJobsForLibrary(LibraryId libraryId, bool downloadMetadataFromWeb)
public IEnumerable<IMediaLibraryScanJob> CreateScanJobsForLibrary(LibraryId libraryId)
{
// declare the list of jobs that this scanner requires
IBooksFileSystemDiscoveryJob fileSystemDiscoveryJob = _mediaScanJobFactory.CreateJob<IBooksFileSystemDiscoveryJob>(libraryId);
@@ -53,14 +52,12 @@ internal class BookLibraryTypeScanner : IBookLibraryTypeScanner
mediaLibraryScanHashJob.AddChild(mediaLibraryScanResultsSaveJob);
mediaLibraryScanResultsSaveJob.AddParent(mediaLibraryScanHashJob);
// when the library permits downloading data from the web, the metadata enrichment job is the last job in the directed acyclic job graph,
// running after the scan results save job, so that the books are materialized before their metadata is enriched
if (downloadMetadataFromWeb)
{
IMediaLibraryScanMetadataEnrichmentJob mediaLibraryScanMetadataEnrichmentJob = _mediaScanJobFactory.CreateJob<IMediaLibraryScanMetadataEnrichmentJob>(libraryId);
mediaLibraryScanResultsSaveJob.AddChild(mediaLibraryScanMetadataEnrichmentJob);
mediaLibraryScanMetadataEnrichmentJob.AddParent(mediaLibraryScanResultsSaveJob);
}
// the metadata enrichment job is always the last job in the directed acyclic job graph, running after the scan results save job,
// so that the books are materialized before their metadata is enriched. The job itself is the host-side gate that skips the providers
// requiring access to the web when the media library does not permit downloading data from the web, so that the local providers still run offline
IMediaLibraryScanMetadataEnrichmentJob mediaLibraryScanMetadataEnrichmentJob = _mediaScanJobFactory.CreateJob<IMediaLibraryScanMetadataEnrichmentJob>(libraryId);
mediaLibraryScanResultsSaveJob.AddChild(mediaLibraryScanMetadataEnrichmentJob);
mediaLibraryScanMetadataEnrichmentJob.AddParent(mediaLibraryScanResultsSaveJob);
// return the top level jobs that will be triggered when the scan will be started
yield return fileSystemDiscoveryJob;