From 36f58b64d6a49963e7f8a697f3c4dcc0c3eece72 Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Sun, 26 Sep 2021 23:05:17 +1300 Subject: [PATCH] proof of concept --- AaxDecrypter/AaxcDownloadConverter.cs | 37 +++++++++++++++++++-------- AaxDecrypter/AudiobookDownloadBase.cs | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/AaxDecrypter/AaxcDownloadConverter.cs b/AaxDecrypter/AaxcDownloadConverter.cs index 0fa7606b..7587c2fd 100644 --- a/AaxDecrypter/AaxcDownloadConverter.cs +++ b/AaxDecrypter/AaxcDownloadConverter.cs @@ -26,7 +26,7 @@ namespace AaxDecrypter ["Step 1: Get Aaxc Metadata"] = Step1_GetMetadata, ["Step 2: Download Decrypted Audiobook"] = Step2_DownloadAudiobook, - ["Step 3: Create Cue"] = Step3_CreateCue, + //["Step 3: Create Cue"] = Step3_CreateCue, ["Step 4: Cleanup"] = Step4_Cleanup, }; } @@ -67,25 +67,40 @@ namespace AaxDecrypter aaxFile.SetDecryptionKey(downloadLicense.AudibleKey, downloadLicense.AudibleIV); - - if (File.Exists(outputFileName)) - FileExt.SafeDelete(outputFileName); - - var outputFile = File.Open(outputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); - aaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; - var decryptionResult = OutputFormat == OutputFormat.M4b ? aaxFile.ConvertToMp4a(outputFile, downloadLicense.ChapterInfo) : aaxFile.ConvertToMp3(outputFile); + //var decryptionResult = OutputFormat == OutputFormat.Mp4a ? aaxFile.ConvertToMp4a(outFile, downloadLicense.ChapterInfo) : aaxFile.ConvertToMp3(outFile); + + var chapterCount = 0; + //aaxFile.ConvertToMultiMp4a(downloadLicense.ChapterInfo, newSplitCallback => + aaxFile.ConvertToMultiMp3(downloadLicense.ChapterInfo, newSplitCallback => + { + chapterCount++; + var fileName = Path.ChangeExtension(outputFileName, $"{chapterCount}.mp3"); + if (File.Exists(fileName)) + FileExt.SafeDelete(fileName); + newSplitCallback.OutputFile = File.Open(fileName, FileMode.OpenOrCreate); + newSplitCallback.LameConfig = new NAudio.Lame.LameConfig + { + ID3 = new NAudio.Lame.ID3TagData() + { + Track = chapterCount.ToString(), + Artist = aaxFile.AppleTags.AlbumArtists, + Album = aaxFile.AppleTags.Album, + Title = aaxFile.AppleTags.Title, + Genre = aaxFile.AppleTags.Generes + } + }; + }); + aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; aaxFile.Close(); - downloadLicense.ChapterInfo = aaxFile.Chapters; - CloseInputFileStream(); OnDecryptProgressUpdate(zeroProgress); - return decryptionResult == ConversionResult.NoErrorsDetected && !isCanceled; + return true; } private void AaxFile_ConversionProgressUpdate(object sender, ConversionProgressEventArgs e) diff --git a/AaxDecrypter/AudiobookDownloadBase.cs b/AaxDecrypter/AudiobookDownloadBase.cs index 7a2425d4..f6a41baa 100644 --- a/AaxDecrypter/AudiobookDownloadBase.cs +++ b/AaxDecrypter/AudiobookDownloadBase.cs @@ -80,7 +80,7 @@ namespace AaxDecrypter return false; } - Serilog.Log.Logger.Information($"Speedup is {GetSpeedup(Elapsed)}x realtime."); + //Serilog.Log.Logger.Information($"Speedup is {GetSpeedup(Elapsed)}x realtime."); return true; }