Move OutputFormat to DownloadLicense

This commit is contained in:
Michael Bucari-Tovo 2022-05-08 09:40:08 -06:00
parent 77de70762c
commit c0516772a7
4 changed files with 16 additions and 22 deletions

View File

@ -8,15 +8,10 @@ namespace AaxDecrypter
{ {
public event EventHandler<AppleTags> RetrievedMetadata; public event EventHandler<AppleTags> RetrievedMetadata;
protected OutputFormat OutputFormat { get; }
protected AaxFile AaxFile; protected AaxFile AaxFile;
protected AaxcDownloadConvertBase(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat) protected AaxcDownloadConvertBase(string outFileName, string cacheDirectory, DownloadLicense dlLic)
: base(outFileName, cacheDirectory, dlLic) : base(outFileName, cacheDirectory, dlLic) { }
{
OutputFormat = outputFormat;
}
/// <summary>Setting cover art by this method will insert the art into the audiobook metadata</summary> /// <summary>Setting cover art by this method will insert the art into the audiobook metadata</summary>
public override void SetCoverArt(byte[] coverArt) public override void SetCoverArt(byte[] coverArt)

View File

@ -18,13 +18,13 @@ namespace AaxDecrypter
private static TimeSpan minChapterLength { get; } = TimeSpan.FromSeconds(3); private static TimeSpan minChapterLength { get; } = TimeSpan.FromSeconds(3);
private List<string> multiPartFilePaths { get; } = new List<string>(); private List<string> multiPartFilePaths { get; } = new List<string>();
public AaxcDownloadMultiConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat, public AaxcDownloadMultiConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic,
Func<MultiConvertFileProperties, string> multipartFileNameCallback = null) Func<MultiConvertFileProperties, string> multipartFileNameCallback = null)
: base(outFileName, cacheDirectory, dlLic, outputFormat) : base(outFileName, cacheDirectory, dlLic)
{ {
Steps = new StepSequence 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 1: Get Aaxc Metadata"] = Step_GetMetadata,
["Step 2: Download Decrypted Audiobook"] = Step_DownloadAudiobookAsMultipleFilesPerChapter, ["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; ConversionResult result;
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
if (OutputFormat == OutputFormat.M4b) if (DownloadLicense.OutputFormat == OutputFormat.M4b)
result = ConvertToMultiMp4a(splitChapters); result = ConvertToMultiMp4a(splitChapters);
else else
result = ConvertToMultiMp3(splitChapters); result = ConvertToMultiMp3(splitChapters);

View File

@ -11,12 +11,12 @@ namespace AaxDecrypter
{ {
protected override StepSequence Steps { get; } protected override StepSequence Steps { get; }
public AaxcDownloadSingleConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat) public AaxcDownloadSingleConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic)
: base(outFileName, cacheDirectory, dlLic, outputFormat) : base(outFileName, cacheDirectory, dlLic)
{ {
Steps = new StepSequence 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 1: Get Aaxc Metadata"] = Step_GetMetadata,
["Step 2: Download Decrypted Audiobook"] = Step_DownloadAudiobookAsSingleFile, ["Step 2: Download Decrypted Audiobook"] = Step_DownloadAudiobookAsSingleFile,
@ -35,7 +35,7 @@ namespace AaxDecrypter
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
var decryptionResult var decryptionResult
= OutputFormat == OutputFormat.M4b = DownloadLicense.OutputFormat == OutputFormat.M4b
? AaxFile.ConvertToMp4a(outputFile, DownloadLicense.ChapterInfo, DownloadLicense.TrimOutputToChapterLength) ? AaxFile.ConvertToMp4a(outputFile, DownloadLicense.ChapterInfo, DownloadLicense.TrimOutputToChapterLength)
: AaxFile.ConvertToMp3(outputFile, null, DownloadLicense.ChapterInfo, DownloadLicense.TrimOutputToChapterLength); : AaxFile.ConvertToMp3(outputFile, null, DownloadLicense.ChapterInfo, DownloadLicense.TrimOutputToChapterLength);
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;

View File

@ -6,20 +6,19 @@ namespace AaxDecrypter
public class DownloadLicense public class DownloadLicense
{ {
public string DownloadUrl { get; } public string DownloadUrl { get; }
public string AudibleKey { get; }
public string AudibleIV { get; }
public string UserAgent { 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 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)); DownloadUrl = ArgumentValidator.EnsureNotNullOrEmpty(downloadUrl, nameof(downloadUrl));
UserAgent = ArgumentValidator.EnsureNotNullOrEmpty(userAgent, nameof(userAgent)); UserAgent = ArgumentValidator.EnsureNotNullOrEmpty(userAgent, nameof(userAgent));
// no null/empty check. unencrypted files do not have these // no null/empty check for key/iv. unencrypted files do not have them
AudibleKey = audibleKey;
AudibleIV = audibleIV;
} }
} }
} }