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

@@ -110,14 +110,14 @@ public static class BookEntityMapping
Optional<BookFormat> bookFormat = Optional<BookFormat>.FromNullable(repositoryEntity.Format);
return Book.Create(
Result<Book> bookResult = Book.Create(
BookId.Create(repositoryEntity.Id),
LibraryId.Create(repositoryEntity.LibraryId),
repositoryEntity.Path,
writtenContentMetadataResult.Value,
bookFormat,
Optional<string>.FromNullable(repositoryEntity.Edition),
Optional<int>.FromNullable(repositoryEntity.VolumeNumber),
Optional<float>.FromNullable(repositoryEntity.VolumeNumber),
Optional<BookSeries>.None(),
Optional<string>.FromNullable(repositoryEntity.ASIN),
Optional<string>.FromNullable(repositoryEntity.GoodreadsId),
@@ -133,6 +133,13 @@ public static class BookEntityMapping
[.. isbnsResult.Select(isbn => isbn.Value)],
[],
[.. bookRatingsResult.Select(bookRating => bookRating.Value)]);
if (bookResult.IsFailure)
return bookResult.Errors;
if (repositoryEntity.CoverImagePath is not null)
bookResult.Value.SetBookCoverImagePath(repositoryEntity.CoverImagePath);
return bookResult;
}
/// <summary>
@@ -217,7 +224,8 @@ public static class BookEntityMapping
repositoryEntity.LastMetadataUpdateUtc,
repositoryEntity.MetadataProvider,
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
repositoryEntity.UpdatedOnUtc,
repositoryEntity.CoverImagePath
);
}
@@ -259,8 +267,7 @@ public static class BookEntityMapping
repositoryEntity.Id,
repositoryEntity.Title,
repositoryEntity.ReReleaseYear ?? repositoryEntity.OriginalReleaseYear,
// TODO: populate from the book cover when cover support is implemented
null
repositoryEntity.CoverImagePath
);
}
@@ -56,6 +56,7 @@ public static class BookMapping
GoogleBooksId = domainEntity.GoogleBooksId.HasValue ? domainEntity.GoogleBooksId.Value : null,
BarnesAndNobleId = domainEntity.BarnesAndNobleId.HasValue ? domainEntity.BarnesAndNobleId.Value : null,
AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null,
CoverImagePath = domainEntity.CoverImagePath.HasValue ? domainEntity.CoverImagePath.Value : null,
ISBNs = [.. domainEntity.ISBNs.ToRepositoryEntities()],
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()],
MetadataStatus = domainEntity.MetadataStatus,
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
@@ -30,9 +29,9 @@ public static class BookMetadataDtoMapping
public static Result<Success> ApplyMetadata(this Book book, BookMetadataDto metadata, string providerName, DateTime lastUpdateUtc)
{
if (string.IsNullOrWhiteSpace(metadata.Title))
return Lumina.Domain.Common.Errors.Errors.Metadata.TitleCannotBeEmpty;
return Domain.Common.Errors.Errors.Metadata.TitleCannotBeEmpty;
if (metadata.ReleaseInfo is null)
return Lumina.Domain.Common.Errors.Errors.Metadata.ReleaseInfoCannotBeNull;
return Domain.Common.Errors.Errors.Metadata.ReleaseInfoCannotBeNull;
Result<ReleaseInfo> releaseInfoResult = ReleaseInfo.Create(
Optional<DateOnly>.FromNullable(metadata.ReleaseInfo.OriginalReleaseDate),
@@ -115,7 +114,7 @@ public static class BookMetadataDtoMapping
writtenContentMetadataResult.Value,
Optional<BookFormat>.FromNullable(metadata.Format.HasValue ? (BookFormat)(int)metadata.Format.Value : (BookFormat?)null),
Optional<string>.FromNullable(metadata.Edition),
Optional<int>.FromNullable(metadata.VolumeNumber),
Optional<float>.FromNullable(metadata.VolumeNumber),
Optional<BookSeries>.None(),
Optional<string>.FromNullable(metadata.ASIN),
Optional<string>.FromNullable(metadata.GoodreadsId),
@@ -132,6 +131,9 @@ public static class BookMetadataDtoMapping
lastUpdateUtc
);
if (!string.IsNullOrWhiteSpace(metadata.CoverImagePath))
book.SetBookCoverImagePath(metadata.CoverImagePath);
return Result.Success;
}
}
@@ -21,18 +21,19 @@ public static class GetBooksLiteRequestMapping
{
PaginationDataDto? paginationData = null;
if (request.CurrentPage is not null || request.PerPage is not null)
{
paginationData = new PaginationDataDto
{
CurrentPage = request.CurrentPage ?? 1,
PerPage = request.PerPage ?? 200
};
}
LibraryFilterDto libraryFilter = new()
{
LibraryId = request.LibraryId,
SearchTerm = request.SearchTerm,
FilterAlphaKey = request.FilterAlphaKey,
IgnoreThePrefixForAlphaPicker = request.IgnoreThePrefixForAlphaPicker
ShouldIgnoreThePrefixForAlphaPicker = request.ShouldIgnoreThePrefixForAlphaPicker
};
return new GetBooksLiteQuery(paginationData, libraryFilter, request.SortBy, request.SortOrder);