From 6be44966ad2200e1f2de45a69330d51d5b7d9ba7 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Mon, 25 Apr 2022 13:23:43 -0400 Subject: [PATCH] * enhancement #202 : use audible category for file's genre metatag. Thanks @MBucari ! --- AaxDecrypter/AaxcDownloadConvertBase.cs | 5 +++++ DataLayer/DataLayer.csproj | 6 +++--- FileLiberator/DownloadDecryptBook.cs | 16 ++++++++++++++-- .../AudibleUtilities.Tests.csproj | 6 +++--- .../FileLiberator.Tests.csproj | 6 +++--- .../FileManager.Tests/FileManager.Tests.csproj | 6 +++--- .../LibationFileManager.Tests.csproj | 6 +++--- .../LibationSearchEngine.Tests.csproj | 6 +++--- 8 files changed, 37 insertions(+), 20 deletions(-) diff --git a/AaxDecrypter/AaxcDownloadConvertBase.cs b/AaxDecrypter/AaxcDownloadConvertBase.cs index 6e2b4568..b4959c3f 100644 --- a/AaxDecrypter/AaxcDownloadConvertBase.cs +++ b/AaxDecrypter/AaxcDownloadConvertBase.cs @@ -24,10 +24,15 @@ namespace AaxDecrypter AaxFile?.AppleTags.SetCoverArt(coverArt); } + /// Optional step to run after Metadata is retrieved + public Action UpdateMetadata { get; set; } + protected bool Step_GetMetadata() { AaxFile = new AaxFile(InputFileStream); + UpdateMetadata?.Invoke(AaxFile); + OnRetrievedTitle(AaxFile.AppleTags.TitleSansUnabridged); OnRetrievedAuthors(AaxFile.AppleTags.FirstAuthor ?? "[unknown]"); OnRetrievedNarrators(AaxFile.AppleTags.Narrator ?? "[unknown]"); diff --git a/DataLayer/DataLayer.csproj b/DataLayer/DataLayer.csproj index 93e05cd2..64a4f93d 100644 --- a/DataLayer/DataLayer.csproj +++ b/DataLayer/DataLayer.csproj @@ -13,12 +13,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/FileLiberator/DownloadDecryptBook.cs b/FileLiberator/DownloadDecryptBook.cs index f169f80d..cd092fb9 100644 --- a/FileLiberator/DownloadDecryptBook.cs +++ b/FileLiberator/DownloadDecryptBook.cs @@ -119,9 +119,21 @@ namespace FileLiberator var cacheDir = AudibleFileStorage.DownloadsInProgressDirectory; + if (contentLic.DrmType != AudibleApi.Common.DrmType.Adrm) + abDownloader = new UnencryptedAudiobookDownloader(outFileName, cacheDir, audiobookDlLic); + else + { + AaxcDownloadConvertBase converter + = Configuration.Instance.SplitFilesByChapter ? new AaxcDownloadMultiConverter( + outFileName, cacheDir, audiobookDlLic, outputFormat, + AudibleFileStorage.Audio.CreateMultipartRenamerFunc(libraryBook)) + : new AaxcDownloadSingleConverter(outFileName, cacheDir, audiobookDlLic, outputFormat); + converter.UpdateMetadata = aaxFile => aaxFile.AppleTags.Generes = string.Join(", ", libraryBook.Book.CategoriesNames); + abDownloader = converter; + } + abDownloader - = contentLic.DrmType != AudibleApi.Common.DrmType.Adrm ? new UnencryptedAudiobookDownloader(outFileName, cacheDir, audiobookDlLic) - : Configuration.Instance.SplitFilesByChapter ? new AaxcDownloadMultiConverter( + = Configuration.Instance.SplitFilesByChapter ? new AaxcDownloadMultiConverter( outFileName, cacheDir, audiobookDlLic, outputFormat, AudibleFileStorage.Audio.CreateMultipartRenamerFunc(libraryBook) ) diff --git a/_Tests/AudibleUtilities.Tests/AudibleUtilities.Tests.csproj b/_Tests/AudibleUtilities.Tests/AudibleUtilities.Tests.csproj index 7af125b7..f6e93c74 100644 --- a/_Tests/AudibleUtilities.Tests/AudibleUtilities.Tests.csproj +++ b/_Tests/AudibleUtilities.Tests/AudibleUtilities.Tests.csproj @@ -7,11 +7,11 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/_Tests/FileLiberator.Tests/FileLiberator.Tests.csproj b/_Tests/FileLiberator.Tests/FileLiberator.Tests.csproj index 70c85bab..2a7dc57f 100644 --- a/_Tests/FileLiberator.Tests/FileLiberator.Tests.csproj +++ b/_Tests/FileLiberator.Tests/FileLiberator.Tests.csproj @@ -7,10 +7,10 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/_Tests/FileManager.Tests/FileManager.Tests.csproj b/_Tests/FileManager.Tests/FileManager.Tests.csproj index 8676036c..09705688 100644 --- a/_Tests/FileManager.Tests/FileManager.Tests.csproj +++ b/_Tests/FileManager.Tests/FileManager.Tests.csproj @@ -7,10 +7,10 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/_Tests/LibationFileManager.Tests/LibationFileManager.Tests.csproj b/_Tests/LibationFileManager.Tests/LibationFileManager.Tests.csproj index eb8700c9..3eb622b1 100644 --- a/_Tests/LibationFileManager.Tests/LibationFileManager.Tests.csproj +++ b/_Tests/LibationFileManager.Tests/LibationFileManager.Tests.csproj @@ -7,10 +7,10 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/_Tests/LibationSearchEngine.Tests/LibationSearchEngine.Tests.csproj b/_Tests/LibationSearchEngine.Tests/LibationSearchEngine.Tests.csproj index f6ca4b2c..619508a3 100644 --- a/_Tests/LibationSearchEngine.Tests/LibationSearchEngine.Tests.csproj +++ b/_Tests/LibationSearchEngine.Tests/LibationSearchEngine.Tests.csproj @@ -7,11 +7,11 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive