From 07eaa48e1052c03da0494d9d5e7480ca07810fca Mon Sep 17 00:00:00 2001 From: MBucari Date: Sun, 16 Jul 2023 10:54:05 -0600 Subject: [PATCH] Save raw json metadata --- Source/FileLiberator/DownloadDecryptBook.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Source/FileLiberator/DownloadDecryptBook.cs b/Source/FileLiberator/DownloadDecryptBook.cs index 9ecc8ae0..cbcf2336 100644 --- a/Source/FileLiberator/DownloadDecryptBook.cs +++ b/Source/FileLiberator/DownloadDecryptBook.cs @@ -160,21 +160,16 @@ namespace FileLiberator { var metadataFile = Templates.File.GetFilename(dlOptions.LibraryBookDto, Path.GetDirectoryName(outFileName), ".metadata.json"); - saveMetadata(libraryBook, contentLic.ContentMetadata, metadataFile); + var item = await api.GetCatalogProductAsync(libraryBook.Book.AudibleProductId, AudibleApi.CatalogOptions.ResponseGroupOptions.ALL_OPTIONS); + item.SourceJson.Add(nameof(ContentMetadata.ChapterInfo), Newtonsoft.Json.Linq.JObject.FromObject(contentLic.ContentMetadata.ChapterInfo)); + item.SourceJson.Add(nameof(ContentMetadata.ContentReference), Newtonsoft.Json.Linq.JObject.FromObject(contentLic.ContentMetadata.ContentReference)); + + File.WriteAllText(metadataFile, item.SourceJson.ToString()); + OnFileCreated(libraryBook, metadataFile); } return success; } - private void saveMetadata(LibraryBook libraryBook, ContentMetadata contentMetadata, string fileName) - { - var export = Newtonsoft.Json.Linq.JObject.FromObject(LibToDtos.ToDtos(new[] { libraryBook })[0]); - export.Add(nameof(contentMetadata.ChapterInfo), Newtonsoft.Json.Linq.JObject.FromObject(contentMetadata.ChapterInfo)); - export.Add(nameof(contentMetadata.ContentReference), Newtonsoft.Json.Linq.JObject.FromObject(contentMetadata.ContentReference)); - - File.WriteAllText(fileName, export.ToString()); - OnFileCreated(libraryBook, fileName); - } - private DownloadOptions BuildDownloadOptions(LibraryBook libraryBook, Configuration config, ContentLicense contentLic) { //If DrmType != Adrm the delivered file is an unencrypted mp3.