From fbb287cffd38b2ffb44e2ccc129a38c8d17ed65a Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 21 Apr 2024 01:01:36 -0400 Subject: [PATCH] feat: save file metadata --- src/LibroFmClient.ts | 2 +- src/lib/DownloadClient.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/LibroFmClient.ts b/src/LibroFmClient.ts index f3b5608..8b9b96b 100644 --- a/src/LibroFmClient.ts +++ b/src/LibroFmClient.ts @@ -115,7 +115,7 @@ export default class LibroFmClient { keepZip ); - await DownloadCLient.saveMetadata(book, path); + await DownloadCLient.saveMetadata(book, metadata, path); this.state.addBook({ book, diff --git a/src/lib/DownloadClient.ts b/src/lib/DownloadClient.ts index 1f4fbd7..4d8f324 100644 --- a/src/lib/DownloadClient.ts +++ b/src/lib/DownloadClient.ts @@ -51,10 +51,14 @@ export default class DownloadCLient { @LogMethod({ scope, message: "Saving metadata..." }) static async saveMetadata( book: Audiobook, + fileData: DownloadMetadata, filepath: string ): Promise { const metadataPath = path.join(filepath, "metadata.json"); - fs.writeFileSync(metadataPath, JSON.stringify(book, null, 2)); + fs.writeFileSync( + metadataPath, + JSON.stringify({ book, fileData }, null, 2) + ); } /** Downloads a file from a URL and returns the data as a Uint8Array */