feat: Add Book Ingestion Modal for local EPUB metadata extraction (fixes #33)
This commit is contained in:
@@ -35,4 +35,19 @@ public class WasmEpubService : IEpubService
|
||||
return Result.Fail(new Error($"Network or parsing error: {ex.Message}").CausedBy(ex));
|
||||
}
|
||||
}
|
||||
public async Task<Result<LocalEpubMetadata>> ExtractMetadataAsync(Stream epubStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bookRef = await VersOne.Epub.EpubReader.OpenBookAsync(epubStream);
|
||||
var title = bookRef.Title ?? "Unknown Title";
|
||||
var author = bookRef.Author ?? "Unknown Author";
|
||||
byte[]? cover = await bookRef.ReadCoverAsync();
|
||||
return Result.Ok(new LocalEpubMetadata(title, author, cover));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(new Error($"Failed to extract EPUB metadata locally: {ex.Message}").CausedBy(ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user