Skip to content

Commit

Permalink
feat: save file metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1230 committed Apr 21, 2024
1 parent 7f2cf2e commit fbb287c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/LibroFmClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class LibroFmClient {
keepZip
);

await DownloadCLient.saveMetadata(book, path);
await DownloadCLient.saveMetadata(book, metadata, path);

this.state.addBook({
book,
Expand Down
6 changes: 5 additions & 1 deletion src/lib/DownloadClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ export default class DownloadCLient {
@LogMethod({ scope, message: "Saving metadata..." })
static async saveMetadata(
book: Audiobook,
fileData: DownloadMetadata,
filepath: string
): Promise<void> {
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 */
Expand Down

0 comments on commit fbb287c

Please sign in to comment.