From c0516772a7a92d3de424c8c0fb11777530b73b03 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sun, 8 May 2022 09:40:08 -0600 Subject: [PATCH] Move OutputFormat to DownloadLicense --- AaxDecrypter/AaxcDownloadConvertBase.cs | 9 ++------- AaxDecrypter/AaxcDownloadMultiConverter.cs | 8 ++++---- AaxDecrypter/AaxcDownloadSingleConverter.cs | 8 ++++---- AaxDecrypter/DownloadLicense.cs | 13 ++++++------- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/AaxDecrypter/AaxcDownloadConvertBase.cs b/AaxDecrypter/AaxcDownloadConvertBase.cs index 726d1efd..4784be37 100644 --- a/AaxDecrypter/AaxcDownloadConvertBase.cs +++ b/AaxDecrypter/AaxcDownloadConvertBase.cs @@ -8,15 +8,10 @@ namespace AaxDecrypter { public event EventHandler RetrievedMetadata; - protected OutputFormat OutputFormat { get; } - protected AaxFile AaxFile; - protected AaxcDownloadConvertBase(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat) - : base(outFileName, cacheDirectory, dlLic) - { - OutputFormat = outputFormat; - } + protected AaxcDownloadConvertBase(string outFileName, string cacheDirectory, DownloadLicense dlLic) + : base(outFileName, cacheDirectory, dlLic) { } /// Setting cover art by this method will insert the art into the audiobook metadata public override void SetCoverArt(byte[] coverArt) diff --git a/AaxDecrypter/AaxcDownloadMultiConverter.cs b/AaxDecrypter/AaxcDownloadMultiConverter.cs index 2835a2eb..ba4dc68c 100644 --- a/AaxDecrypter/AaxcDownloadMultiConverter.cs +++ b/AaxDecrypter/AaxcDownloadMultiConverter.cs @@ -18,13 +18,13 @@ namespace AaxDecrypter private static TimeSpan minChapterLength { get; } = TimeSpan.FromSeconds(3); private List multiPartFilePaths { get; } = new List(); - public AaxcDownloadMultiConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat, + public AaxcDownloadMultiConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, Func multipartFileNameCallback = null) - : base(outFileName, cacheDirectory, dlLic, outputFormat) + : base(outFileName, cacheDirectory, dlLic) { Steps = new StepSequence { - Name = "Download and Convert Aaxc To " + OutputFormat, + Name = "Download and Convert Aaxc To " + DownloadLicense.OutputFormat, ["Step 1: Get Aaxc Metadata"] = Step_GetMetadata, ["Step 2: Download Decrypted Audiobook"] = Step_DownloadAudiobookAsMultipleFilesPerChapter, @@ -89,7 +89,7 @@ That naming may not be desirable for everyone, but it's an easy change to instea ConversionResult result; AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; - if (OutputFormat == OutputFormat.M4b) + if (DownloadLicense.OutputFormat == OutputFormat.M4b) result = ConvertToMultiMp4a(splitChapters); else result = ConvertToMultiMp3(splitChapters); diff --git a/AaxDecrypter/AaxcDownloadSingleConverter.cs b/AaxDecrypter/AaxcDownloadSingleConverter.cs index d047d94e..0592d108 100644 --- a/AaxDecrypter/AaxcDownloadSingleConverter.cs +++ b/AaxDecrypter/AaxcDownloadSingleConverter.cs @@ -11,12 +11,12 @@ namespace AaxDecrypter { protected override StepSequence Steps { get; } - public AaxcDownloadSingleConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat) - : base(outFileName, cacheDirectory, dlLic, outputFormat) + public AaxcDownloadSingleConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic) + : base(outFileName, cacheDirectory, dlLic) { Steps = new StepSequence { - Name = "Download and Convert Aaxc To " + OutputFormat, + Name = "Download and Convert Aaxc To " + DownloadLicense.OutputFormat, ["Step 1: Get Aaxc Metadata"] = Step_GetMetadata, ["Step 2: Download Decrypted Audiobook"] = Step_DownloadAudiobookAsSingleFile, @@ -35,7 +35,7 @@ namespace AaxDecrypter AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; var decryptionResult - = OutputFormat == OutputFormat.M4b + = DownloadLicense.OutputFormat == OutputFormat.M4b ? AaxFile.ConvertToMp4a(outputFile, DownloadLicense.ChapterInfo, DownloadLicense.TrimOutputToChapterLength) : AaxFile.ConvertToMp3(outputFile, null, DownloadLicense.ChapterInfo, DownloadLicense.TrimOutputToChapterLength); AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; diff --git a/AaxDecrypter/DownloadLicense.cs b/AaxDecrypter/DownloadLicense.cs index b92166e5..51b69c71 100644 --- a/AaxDecrypter/DownloadLicense.cs +++ b/AaxDecrypter/DownloadLicense.cs @@ -6,20 +6,19 @@ namespace AaxDecrypter public class DownloadLicense { public string DownloadUrl { get; } - public string AudibleKey { get; } - public string AudibleIV { get; } public string UserAgent { get; } + public string AudibleKey { get; init; } + public string AudibleIV { get; init; } + public OutputFormat OutputFormat { get; init; } + public bool TrimOutputToChapterLength { get; init; } public ChapterInfo ChapterInfo { get; set; } - public bool TrimOutputToChapterLength { get; set; } - public DownloadLicense(string downloadUrl, string audibleKey, string audibleIV, string userAgent) + public DownloadLicense(string downloadUrl, string userAgent) { DownloadUrl = ArgumentValidator.EnsureNotNullOrEmpty(downloadUrl, nameof(downloadUrl)); UserAgent = ArgumentValidator.EnsureNotNullOrEmpty(userAgent, nameof(userAgent)); - // no null/empty check. unencrypted files do not have these - AudibleKey = audibleKey; - AudibleIV = audibleIV; + // no null/empty check for key/iv. unencrypted files do not have them } } }