Added MP3 conversion option.

This commit is contained in:
Michael Bucari-Tovo 2021-07-18 17:18:35 -06:00
parent 8997f52505
commit 7df8c7427c
6 changed files with 217 additions and 140 deletions

View File

@ -8,6 +8,11 @@ using System.IO;
namespace AaxDecrypter namespace AaxDecrypter
{ {
public enum OutputFormat
{
Mp4a,
Mp3
}
public class AaxcDownloadConverter public class AaxcDownloadConverter
{ {
public event EventHandler<AppleTags> RetrievedTags; public event EventHandler<AppleTags> RetrievedTags;
@ -21,6 +26,7 @@ namespace AaxDecrypter
private DownloadLicense downloadLicense { get; } private DownloadLicense downloadLicense { get; }
private AaxFile aaxFile; private AaxFile aaxFile;
private byte[] coverArt; private byte[] coverArt;
private OutputFormat OutputFormat;
private StepSequence steps { get; } private StepSequence steps { get; }
private NetworkFileStreamPersister nfsPersister; private NetworkFileStreamPersister nfsPersister;
@ -28,10 +34,10 @@ namespace AaxDecrypter
private string jsonDownloadState => Path.Combine(cacheDir, Path.GetFileNameWithoutExtension(OutputFileName) + ".json"); private string jsonDownloadState => Path.Combine(cacheDir, Path.GetFileNameWithoutExtension(OutputFileName) + ".json");
private string tempFile => PathLib.ReplaceExtension(jsonDownloadState, ".aaxc"); private string tempFile => PathLib.ReplaceExtension(jsonDownloadState, ".aaxc");
public AaxcDownloadConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic) public AaxcDownloadConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat)
{ {
ArgumentValidator.EnsureNotNullOrWhiteSpace(outFileName, nameof(outFileName)); ArgumentValidator.EnsureNotNullOrWhiteSpace(outFileName, nameof(outFileName));
OutputFileName = PathLib.ReplaceExtension(outFileName, ".m4b"); OutputFileName = outFileName;
var outDir = Path.GetDirectoryName(OutputFileName); var outDir = Path.GetDirectoryName(OutputFileName);
if (!Directory.Exists(outDir)) if (!Directory.Exists(outDir))
throw new ArgumentNullException(nameof(outDir), "Directory does not exist"); throw new ArgumentNullException(nameof(outDir), "Directory does not exist");
@ -43,6 +49,7 @@ namespace AaxDecrypter
cacheDir = cacheDirectory; cacheDir = cacheDirectory;
downloadLicense = ArgumentValidator.EnsureNotNull(dlLic, nameof(dlLic)); downloadLicense = ArgumentValidator.EnsureNotNull(dlLic, nameof(dlLic));
OutputFormat = outputFormat;
steps = new StepSequence steps = new StepSequence
{ {
@ -125,7 +132,6 @@ namespace AaxDecrypter
public bool Step2_DownloadAndCombine() public bool Step2_DownloadAndCombine()
{ {
OutputFormat format = OutputFormat.Mp4a;
DecryptProgressUpdate?.Invoke(this, 0); DecryptProgressUpdate?.Invoke(this, 0);
@ -134,15 +140,20 @@ namespace AaxDecrypter
FileStream outFile = File.OpenWrite(OutputFileName); FileStream outFile = File.OpenWrite(OutputFileName);
aaxFile.SetDecryptionKey(downloadLicense.AudibleKey, downloadLicense.AudibleIV);
aaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; aaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
var decryptionResult = aaxFile.DecryptAaxc(outFile, downloadLicense.AudibleKey, downloadLicense.AudibleIV, format, downloadLicense.ChapterInfo);
var decryptionResult = OutputFormat == OutputFormat.Mp4a ? aaxFile.ConvertToMp4a(outFile, downloadLicense.ChapterInfo) : aaxFile.ConvertToMp3(outFile);
aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
aaxFile.Close();
downloadLicense.ChapterInfo = aaxFile.Chapters; downloadLicense.ChapterInfo = aaxFile.Chapters;
if (decryptionResult == ConversionResult.NoErrorsDetected if (decryptionResult == ConversionResult.NoErrorsDetected
&& coverArt is not null && coverArt is not null
&& format == OutputFormat.Mp4a) && OutputFormat == OutputFormat.Mp4a)
{ {
//This handles a special case where the aaxc file doesn't contain cover art and //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. //Libation downloaded it instead (Animal Farm). Currently only works for Mp4a files.

View File

@ -87,8 +87,20 @@ namespace FileLiberator
aaxcDecryptDlLic.ChapterInfo.AddChapter(chap.Title, TimeSpan.FromMilliseconds(chap.LengthMs)); aaxcDecryptDlLic.ChapterInfo.AddChapter(chap.Title, TimeSpan.FromMilliseconds(chap.LengthMs));
} }
var proposedOutputFile = Path.Combine(destinationDir, $"{PathLib.ToPathSafeString(libraryBook.Book.Title)} [{libraryBook.Book.AudibleProductId}].m4b");
aaxcDownloader = new AaxcDownloadConverter(proposedOutputFile, cacheDir, aaxcDecryptDlLic) { AppName = "Libation" }; var format = Configuration.Instance.DecryptToLossy ? OutputFormat.Mp3 : OutputFormat.Mp4a;
var extension = format switch
{
OutputFormat.Mp4a => "m4b",
OutputFormat.Mp3 => "mp3",
_ => throw new NotImplementedException(),
};
var proposedOutputFile = Path.Combine(destinationDir, $"{PathLib.ToPathSafeString(libraryBook.Book.Title)} [{libraryBook.Book.AudibleProductId}].{extension}");
aaxcDownloader = new AaxcDownloadConverter(proposedOutputFile, cacheDir, aaxcDecryptDlLic, format) { AppName = "Libation" };
aaxcDownloader.DecryptProgressUpdate += (s, progress) => UpdateProgress?.Invoke(this, progress); aaxcDownloader.DecryptProgressUpdate += (s, progress) => UpdateProgress?.Invoke(this, progress);
aaxcDownloader.DecryptTimeRemaining += (s, remaining) => UpdateRemainingTime?.Invoke(this, remaining); aaxcDownloader.DecryptTimeRemaining += (s, remaining) => UpdateRemainingTime?.Invoke(this, remaining);
aaxcDownloader.RetrievedCoverArt += AaxcDownloader_RetrievedCoverArt; aaxcDownloader.RetrievedCoverArt += AaxcDownloader_RetrievedCoverArt;

View File

@ -121,6 +121,13 @@ namespace FileManager
get => persistentDictionary.Get<bool>(nameof(AllowLibationFixup)); get => persistentDictionary.Get<bool>(nameof(AllowLibationFixup));
set => persistentDictionary.Set(nameof(AllowLibationFixup), value); set => persistentDictionary.Set(nameof(AllowLibationFixup), value);
} }
[Description("Decrypt to lossy format?")]
public bool DecryptToLossy
{
get => persistentDictionary.Get<bool>(nameof(DecryptToLossy));
set => persistentDictionary.Set(nameof(DecryptToLossy), value);
}
// note: any potential file manager static ctors can't compensate if storage dir is changed at run time via settings. this is partly bad architecture. but the side effect is desirable. if changing LibationFiles location: restart app // note: any potential file manager static ctors can't compensate if storage dir is changed at run time via settings. this is partly bad architecture. but the side effect is desirable. if changing LibationFiles location: restart app
// singleton stuff // singleton stuff

View File

@ -13,7 +13,7 @@
<!-- <PublishSingleFile>true</PublishSingleFile> --> <!-- <PublishSingleFile>true</PublishSingleFile> -->
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Version>5.1.10.10</Version> <Version>5.1.10.23</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -28,138 +28,167 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.booksLocationLbl = new System.Windows.Forms.Label(); this.booksLocationLbl = new System.Windows.Forms.Label();
this.booksLocationDescLbl = new System.Windows.Forms.Label(); this.booksLocationDescLbl = new System.Windows.Forms.Label();
this.inProgressDescLbl = new System.Windows.Forms.Label(); this.inProgressDescLbl = new System.Windows.Forms.Label();
this.saveBtn = new System.Windows.Forms.Button(); this.saveBtn = new System.Windows.Forms.Button();
this.cancelBtn = new System.Windows.Forms.Button(); this.cancelBtn = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.inProgressSelectControl = new LibationWinForms.Dialogs.DirectorySelectControl(); this.inProgressSelectControl = new LibationWinForms.Dialogs.DirectorySelectControl();
this.allowLibationFixupCbox = new System.Windows.Forms.CheckBox(); this.allowLibationFixupCbox = new System.Windows.Forms.CheckBox();
this.booksSelectControl = new LibationWinForms.Dialogs.DirectoryOrCustomSelectControl(); this.booksSelectControl = new LibationWinForms.Dialogs.DirectoryOrCustomSelectControl();
this.groupBox1.SuspendLayout(); this.convertLosslessRb = new System.Windows.Forms.RadioButton();
this.SuspendLayout(); this.convertLossyRb = new System.Windows.Forms.RadioButton();
// this.groupBox1.SuspendLayout();
// booksLocationLbl this.SuspendLayout();
// //
this.booksLocationLbl.AutoSize = true; // booksLocationLbl
this.booksLocationLbl.Location = new System.Drawing.Point(13, 15); //
this.booksLocationLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.booksLocationLbl.AutoSize = true;
this.booksLocationLbl.Name = "booksLocationLbl"; this.booksLocationLbl.Location = new System.Drawing.Point(13, 15);
this.booksLocationLbl.Size = new System.Drawing.Size(85, 15); this.booksLocationLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.booksLocationLbl.TabIndex = 0; this.booksLocationLbl.Name = "booksLocationLbl";
this.booksLocationLbl.Text = "Books location"; this.booksLocationLbl.Size = new System.Drawing.Size(85, 15);
// this.booksLocationLbl.TabIndex = 0;
// booksLocationDescLbl this.booksLocationLbl.Text = "Books location";
// //
this.booksLocationDescLbl.AutoSize = true; // booksLocationDescLbl
this.booksLocationDescLbl.Location = new System.Drawing.Point(106, 96); //
this.booksLocationDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.booksLocationDescLbl.AutoSize = true;
this.booksLocationDescLbl.Name = "booksLocationDescLbl"; this.booksLocationDescLbl.Location = new System.Drawing.Point(106, 96);
this.booksLocationDescLbl.Size = new System.Drawing.Size(39, 15); this.booksLocationDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.booksLocationDescLbl.TabIndex = 2; this.booksLocationDescLbl.Name = "booksLocationDescLbl";
this.booksLocationDescLbl.Text = "[desc]"; this.booksLocationDescLbl.Size = new System.Drawing.Size(39, 15);
// this.booksLocationDescLbl.TabIndex = 2;
// inProgressDescLbl this.booksLocationDescLbl.Text = "[desc]";
// //
this.inProgressDescLbl.AutoSize = true; // inProgressDescLbl
this.inProgressDescLbl.Location = new System.Drawing.Point(10, 46); //
this.inProgressDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.inProgressDescLbl.AutoSize = true;
this.inProgressDescLbl.Name = "inProgressDescLbl"; this.inProgressDescLbl.Location = new System.Drawing.Point(10, 46);
this.inProgressDescLbl.Size = new System.Drawing.Size(43, 45); this.inProgressDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.inProgressDescLbl.TabIndex = 1; this.inProgressDescLbl.Name = "inProgressDescLbl";
this.inProgressDescLbl.Text = "[desc]\r\n[line 2]\r\n[line 3]"; this.inProgressDescLbl.Size = new System.Drawing.Size(43, 45);
// this.inProgressDescLbl.TabIndex = 1;
// saveBtn this.inProgressDescLbl.Text = "[desc]\r\n[line 2]\r\n[line 3]";
// //
this.saveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); // saveBtn
this.saveBtn.Location = new System.Drawing.Point(714, 275); //
this.saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.saveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.saveBtn.Name = "saveBtn"; this.saveBtn.Location = new System.Drawing.Point(714, 268);
this.saveBtn.Size = new System.Drawing.Size(88, 27); this.saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.saveBtn.TabIndex = 4; this.saveBtn.Name = "saveBtn";
this.saveBtn.Text = "Save"; this.saveBtn.Size = new System.Drawing.Size(88, 27);
this.saveBtn.UseVisualStyleBackColor = true; this.saveBtn.TabIndex = 4;
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click); this.saveBtn.Text = "Save";
// this.saveBtn.UseVisualStyleBackColor = true;
// cancelBtn this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
// //
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); // cancelBtn
this.cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; //
this.cancelBtn.Location = new System.Drawing.Point(832, 275); this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancelBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelBtn.Name = "cancelBtn"; this.cancelBtn.Location = new System.Drawing.Point(832, 268);
this.cancelBtn.Size = new System.Drawing.Size(88, 27); this.cancelBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.cancelBtn.TabIndex = 5; this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Text = "Cancel"; this.cancelBtn.Size = new System.Drawing.Size(88, 27);
this.cancelBtn.UseVisualStyleBackColor = true; this.cancelBtn.TabIndex = 5;
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click); this.cancelBtn.Text = "Cancel";
// this.cancelBtn.UseVisualStyleBackColor = true;
// groupBox1 this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
// //
this.groupBox1.Controls.Add(this.inProgressSelectControl); // groupBox1
this.groupBox1.Controls.Add(this.allowLibationFixupCbox); //
this.groupBox1.Controls.Add(this.inProgressDescLbl); this.groupBox1.Controls.Add(this.convertLossyRb);
this.groupBox1.Location = new System.Drawing.Point(19, 114); this.groupBox1.Controls.Add(this.convertLosslessRb);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.groupBox1.Controls.Add(this.inProgressSelectControl);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Controls.Add(this.allowLibationFixupCbox);
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); this.groupBox1.Controls.Add(this.inProgressDescLbl);
this.groupBox1.Size = new System.Drawing.Size(902, 145); this.groupBox1.Location = new System.Drawing.Point(19, 114);
this.groupBox1.TabIndex = 3; this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.groupBox1.TabStop = false; this.groupBox1.Name = "groupBox1";
this.groupBox1.Text = "Advanced settings for control freaks"; this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
// this.groupBox1.Size = new System.Drawing.Size(902, 143);
// inProgressSelectControl this.groupBox1.TabIndex = 3;
// this.groupBox1.TabStop = false;
this.inProgressSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBox1.Text = "Advanced settings for control freaks";
//
// inProgressSelectControl
//
this.inProgressSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.inProgressSelectControl.Location = new System.Drawing.Point(10, 94); this.inProgressSelectControl.Location = new System.Drawing.Point(10, 94);
this.inProgressSelectControl.Name = "inProgressSelectControl"; this.inProgressSelectControl.Name = "inProgressSelectControl";
this.inProgressSelectControl.Size = new System.Drawing.Size(885, 46); this.inProgressSelectControl.Size = new System.Drawing.Size(885, 46);
this.inProgressSelectControl.TabIndex = 2; this.inProgressSelectControl.TabIndex = 2;
// //
// allowLibationFixupCbox // allowLibationFixupCbox
// //
this.allowLibationFixupCbox.AutoSize = true; this.allowLibationFixupCbox.AutoSize = true;
this.allowLibationFixupCbox.Location = new System.Drawing.Point(10, 24); this.allowLibationFixupCbox.Location = new System.Drawing.Point(10, 24);
this.allowLibationFixupCbox.Name = "allowLibationFixupCbox"; this.allowLibationFixupCbox.Name = "allowLibationFixupCbox";
this.allowLibationFixupCbox.Size = new System.Drawing.Size(262, 19); this.allowLibationFixupCbox.Size = new System.Drawing.Size(262, 19);
this.allowLibationFixupCbox.TabIndex = 0; this.allowLibationFixupCbox.TabIndex = 0;
this.allowLibationFixupCbox.Text = "Allow Libation to fix up audiobook metadata"; this.allowLibationFixupCbox.Text = "Allow Libation to fix up audiobook metadata";
this.allowLibationFixupCbox.UseVisualStyleBackColor = true; this.allowLibationFixupCbox.UseVisualStyleBackColor = true;
// this.allowLibationFixupCbox.CheckedChanged += new System.EventHandler(this.allowLibationFixupCbox_CheckedChanged);
// booksSelectControl //
// // booksSelectControl
this.booksSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) //
this.booksSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.booksSelectControl.Location = new System.Drawing.Point(106, 12); this.booksSelectControl.Location = new System.Drawing.Point(106, 12);
this.booksSelectControl.Name = "booksSelectControl"; this.booksSelectControl.Name = "booksSelectControl";
this.booksSelectControl.Size = new System.Drawing.Size(815, 81); this.booksSelectControl.Size = new System.Drawing.Size(815, 81);
this.booksSelectControl.TabIndex = 1; this.booksSelectControl.TabIndex = 1;
// //
// SettingsDialog // convertLosslessRb
// //
this.AcceptButton = this.saveBtn; this.convertLosslessRb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.convertLosslessRb.AutoSize = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.convertLosslessRb.Checked = true;
this.CancelButton = this.cancelBtn; this.convertLosslessRb.Location = new System.Drawing.Point(692, 24);
this.ClientSize = new System.Drawing.Size(933, 316); this.convertLosslessRb.Name = "convertLosslessRb";
this.Controls.Add(this.booksSelectControl); this.convertLosslessRb.Size = new System.Drawing.Size(108, 19);
this.Controls.Add(this.groupBox1); this.convertLosslessRb.TabIndex = 0;
this.Controls.Add(this.cancelBtn); this.convertLosslessRb.TabStop = true;
this.Controls.Add(this.saveBtn); this.convertLosslessRb.Text = "Mp4a (Lossless)";
this.Controls.Add(this.booksLocationDescLbl); this.convertLosslessRb.UseVisualStyleBackColor = true;
this.Controls.Add(this.booksLocationLbl); //
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; // convertLossyRb
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); //
this.Name = "SettingsDialog"; this.convertLossyRb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.convertLossyRb.AutoSize = true;
this.Text = "Edit Settings"; this.convertLossyRb.Location = new System.Drawing.Point(806, 24);
this.Load += new System.EventHandler(this.SettingsDialog_Load); this.convertLossyRb.Name = "convertLossyRb";
this.groupBox1.ResumeLayout(false); this.convertLossyRb.Size = new System.Drawing.Size(89, 19);
this.groupBox1.PerformLayout(); this.convertLossyRb.TabIndex = 0;
this.ResumeLayout(false); this.convertLossyRb.Text = "Mp3 (Lossy)";
this.PerformLayout(); this.convertLossyRb.UseVisualStyleBackColor = true;
//
// SettingsDialog
//
this.AcceptButton = this.saveBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelBtn;
this.ClientSize = new System.Drawing.Size(933, 309);
this.Controls.Add(this.booksSelectControl);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.saveBtn);
this.Controls.Add(this.booksLocationDescLbl);
this.Controls.Add(this.booksLocationLbl);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "SettingsDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Edit Settings";
this.Load += new System.EventHandler(this.SettingsDialog_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
} }
@ -173,5 +202,7 @@
private System.Windows.Forms.CheckBox allowLibationFixupCbox; private System.Windows.Forms.CheckBox allowLibationFixupCbox;
private DirectoryOrCustomSelectControl booksSelectControl; private DirectoryOrCustomSelectControl booksSelectControl;
private DirectorySelectControl inProgressSelectControl; private DirectorySelectControl inProgressSelectControl;
} private System.Windows.Forms.RadioButton convertLossyRb;
private System.Windows.Forms.RadioButton convertLosslessRb;
}
} }

View File

@ -30,6 +30,10 @@ namespace LibationWinForms.Dialogs
booksSelectControl.SelectDirectory(config.Books); booksSelectControl.SelectDirectory(config.Books);
allowLibationFixupCbox.Checked = config.AllowLibationFixup; allowLibationFixupCbox.Checked = config.AllowLibationFixup;
convertLosslessRb.Checked = !config.DecryptToLossy;
convertLossyRb.Checked = config.DecryptToLossy;
allowLibationFixupCbox_CheckedChanged(this, e);
inProgressSelectControl.SetDirectoryItems(new() inProgressSelectControl.SetDirectoryItems(new()
{ {
@ -45,6 +49,7 @@ namespace LibationWinForms.Dialogs
private void saveBtn_Click(object sender, EventArgs e) private void saveBtn_Click(object sender, EventArgs e)
{ {
config.AllowLibationFixup = allowLibationFixupCbox.Checked; config.AllowLibationFixup = allowLibationFixupCbox.Checked;
config.DecryptToLossy = convertLossyRb.Checked;
config.InProgress = inProgressSelectControl.SelectedDirectory; config.InProgress = inProgressSelectControl.SelectedDirectory;
@ -66,5 +71,16 @@ namespace LibationWinForms.Dialogs
this.DialogResult = DialogResult.Cancel; this.DialogResult = DialogResult.Cancel;
this.Close(); this.Close();
} }
}
private void allowLibationFixupCbox_CheckedChanged(object sender, EventArgs e)
{
convertLosslessRb.Enabled = allowLibationFixupCbox.Checked;
convertLossyRb.Enabled = allowLibationFixupCbox.Checked;
if (!allowLibationFixupCbox.Checked)
{
convertLosslessRb.Checked = true;
}
}
}
} }