From 49f2112c42b02cc01a84ea9b50e32a14977f4fcc Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Wed, 14 Jul 2021 23:52:46 -0600 Subject: [PATCH 1/3] Updated for new AAXClean pattern. --- AaxDecrypter/AaxcDownloadConverter.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/AaxDecrypter/AaxcDownloadConverter.cs b/AaxDecrypter/AaxcDownloadConverter.cs index cd3d8ff1..f1acc9f8 100644 --- a/AaxDecrypter/AaxcDownloadConverter.cs +++ b/AaxDecrypter/AaxcDownloadConverter.cs @@ -175,6 +175,8 @@ namespace AaxDecrypter public bool Step3_DownloadAndCombine() { + OutputFormat format = OutputFormat.Mp3; + DecryptProgressUpdate?.Invoke(this, int.MaxValue); if (File.Exists(outputFileName)) @@ -182,27 +184,32 @@ namespace AaxDecrypter FileStream outFile = File.OpenWrite(outputFileName); - aaxFile.DecryptionProgressUpdate += AaxFile_DecryptionProgressUpdate; - using var decryptedBook = aaxFile.DecryptAaxc(outFile, downloadLicense.AudibleKey, downloadLicense.AudibleIV, downloadLicense.ChapterInfo); - aaxFile.DecryptionProgressUpdate -= AaxFile_DecryptionProgressUpdate; + aaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; + var decryptionResult = aaxFile.DecryptAaxc(outFile, downloadLicense.AudibleKey, downloadLicense.AudibleIV, format, downloadLicense.ChapterInfo); + aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; downloadLicense.ChapterInfo = aaxFile.Chapters; - if (coverArt is not null) + if (decryptionResult == ConversionResult.NoErrorsDetected + && coverArt is not null + && format == OutputFormat.Mp4a) { - decryptedBook?.AppleTags?.SetCoverArt(coverArt); - decryptedBook?.Save(); + //This handles a special case where the aaxc file doesn't contain cover art and + //Libation downloaded it instead (Animal Farm). Currently only works for Mp4a files. + using var decryptedBook = new Mp4File(outputFileName, FileAccess.ReadWrite); + decryptedBook.AppleTags?.SetCoverArt(coverArt); + decryptedBook.Save(); + decryptedBook.Close(); } - decryptedBook?.Close(); nfsPersister.Dispose(); DecryptProgressUpdate?.Invoke(this, 0); - return aaxFile is not null && !isCanceled; + return decryptionResult == ConversionResult.NoErrorsDetected && !isCanceled; } - private void AaxFile_DecryptionProgressUpdate(object sender, DecryptionProgressEventArgs e) + private void AaxFile_ConversionProgressUpdate(object sender, ConversionProgressEventArgs e) { var duration = aaxFile.Duration; double remainingSecsToProcess = (duration - e.ProcessPosition).TotalSeconds; From f986462809ad4bb9032dba86ff505b99b38f4df6 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Wed, 14 Jul 2021 23:58:52 -0600 Subject: [PATCH 2/3] Changed default output type to Mp4a. --- AaxDecrypter/AaxcDownloadConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AaxDecrypter/AaxcDownloadConverter.cs b/AaxDecrypter/AaxcDownloadConverter.cs index f1acc9f8..f7dc13ef 100644 --- a/AaxDecrypter/AaxcDownloadConverter.cs +++ b/AaxDecrypter/AaxcDownloadConverter.cs @@ -175,7 +175,7 @@ namespace AaxDecrypter public bool Step3_DownloadAndCombine() { - OutputFormat format = OutputFormat.Mp3; + OutputFormat format = OutputFormat.Mp4a; DecryptProgressUpdate?.Invoke(this, int.MaxValue); From f5e8e4cd7f85b7561ce81a6c48619640c5fe0637 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Thu, 15 Jul 2021 00:17:59 -0600 Subject: [PATCH 3/3] Removed indeterminate progress bar because decryption stattup time is now insignificant. --- AaxDecrypter/AaxcDownloadConverter.cs | 2 +- LibationWinForms/BookLiberation/DecryptForm.cs | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/AaxDecrypter/AaxcDownloadConverter.cs b/AaxDecrypter/AaxcDownloadConverter.cs index f7dc13ef..f75f2a39 100644 --- a/AaxDecrypter/AaxcDownloadConverter.cs +++ b/AaxDecrypter/AaxcDownloadConverter.cs @@ -177,7 +177,7 @@ namespace AaxDecrypter { OutputFormat format = OutputFormat.Mp4a; - DecryptProgressUpdate?.Invoke(this, int.MaxValue); + DecryptProgressUpdate?.Invoke(this, 0); if (File.Exists(outputFileName)) FileExt.SafeDelete(outputFileName); diff --git a/LibationWinForms/BookLiberation/DecryptForm.cs b/LibationWinForms/BookLiberation/DecryptForm.cs index 6788a774..3dcf7360 100644 --- a/LibationWinForms/BookLiberation/DecryptForm.cs +++ b/LibationWinForms/BookLiberation/DecryptForm.cs @@ -64,14 +64,8 @@ namespace LibationWinForms.BookLiberation if (percentage == 0) remainingTimeLbl.UIThread(() => remainingTimeLbl.Text = "ETA:\r\n0 sec"); - if (percentage == int.MaxValue) - progressBar1.UIThread(() => progressBar1.Style = ProgressBarStyle.Marquee); else - progressBar1.UIThread(() => - { - progressBar1.Value = percentage; - progressBar1.Style = ProgressBarStyle.Blocks; - }); + progressBar1.UIThread(() => progressBar1.Value = percentage); } public void UpdateRemainingTime(TimeSpan remaining)