DecryptKey: static => account instance
This commit is contained in:
parent
3af010c1f5
commit
be84fb317e
@ -8,6 +8,7 @@ using DataLayer;
|
|||||||
using Dinah.Core;
|
using Dinah.Core;
|
||||||
using Dinah.Core.ErrorHandling;
|
using Dinah.Core.ErrorHandling;
|
||||||
using FileManager;
|
using FileManager;
|
||||||
|
using InternalUtilities;
|
||||||
|
|
||||||
namespace FileLiberator
|
namespace FileLiberator
|
||||||
{
|
{
|
||||||
@ -56,7 +57,12 @@ namespace FileLiberator
|
|||||||
return new StatusHandler { "Cannot find decrypt. Final audio file already exists" };
|
return new StatusHandler { "Cannot find decrypt. Final audio file already exists" };
|
||||||
|
|
||||||
var proposedOutputFile = Path.Combine(AudibleFileStorage.DecryptInProgress, $"[{libraryBook.Book.AudibleProductId}].m4b");
|
var proposedOutputFile = Path.Combine(AudibleFileStorage.DecryptInProgress, $"[{libraryBook.Book.AudibleProductId}].m4b");
|
||||||
var outputAudioFilename = await aaxToM4bConverterDecrypt(proposedOutputFile, aaxFilename);
|
|
||||||
|
var account = AudibleApiStorage
|
||||||
|
.GetAccounts()
|
||||||
|
.GetAccount(libraryBook.Account, libraryBook.Book.Locale);
|
||||||
|
|
||||||
|
var outputAudioFilename = await aaxToM4bConverterDecrypt(proposedOutputFile, aaxFilename, account);
|
||||||
|
|
||||||
// decrypt failed
|
// decrypt failed
|
||||||
if (outputAudioFilename == null)
|
if (outputAudioFilename == null)
|
||||||
@ -78,13 +84,13 @@ namespace FileLiberator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> aaxToM4bConverterDecrypt(string proposedOutputFile, string aaxFilename)
|
private async Task<string> aaxToM4bConverterDecrypt(string proposedOutputFile, string aaxFilename, Account account)
|
||||||
{
|
{
|
||||||
DecryptBegin?.Invoke(this, $"Begin decrypting {aaxFilename}");
|
DecryptBegin?.Invoke(this, $"Begin decrypting {aaxFilename}");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var converter = await AaxToM4bConverter.CreateAsync(aaxFilename, Configuration.Instance.DecryptKey);
|
var converter = await AaxToM4bConverter.CreateAsync(aaxFilename, account.DecryptKey);
|
||||||
converter.AppName = "Libation";
|
converter.AppName = "Libation";
|
||||||
|
|
||||||
TitleDiscovered?.Invoke(this, converter.tags.title);
|
TitleDiscovered?.Invoke(this, converter.tags.title);
|
||||||
@ -103,7 +109,7 @@ namespace FileLiberator
|
|||||||
if (!success)
|
if (!success)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Configuration.Instance.DecryptKey = converter.decryptKey;
|
account.DecryptKey = converter.decryptKey;
|
||||||
|
|
||||||
return converter.outputFileName;
|
return converter.outputFileName;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,13 +43,6 @@ namespace FileManager
|
|||||||
|
|
||||||
public string SettingsFilePath => Path.Combine(LibationFiles, "Settings.json");
|
public string SettingsFilePath => Path.Combine(LibationFiles, "Settings.json");
|
||||||
|
|
||||||
[Description("Your user-specific key used to decrypt your audible files (*.aax) into audio files you can use anywhere (*.m4b). Leave alone in most cases")]
|
|
||||||
public string DecryptKey
|
|
||||||
{
|
|
||||||
get => persistentDictionary.GetString(nameof(DecryptKey));
|
|
||||||
set => persistentDictionary.Set(nameof(DecryptKey), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Description("Location for book storage. Includes destination of newly liberated books")]
|
[Description("Location for book storage. Includes destination of newly liberated books")]
|
||||||
public string Books
|
public string Books
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,7 +24,10 @@ namespace InternalUtilities
|
|||||||
=> TEST_GetFirstAccount().GetIdentityTokensJsonPath();
|
=> TEST_GetFirstAccount().GetIdentityTokensJsonPath();
|
||||||
// convenience for for tests and demos. don't use in production Libation
|
// convenience for for tests and demos. don't use in production Libation
|
||||||
public static Account TEST_GetFirstAccount()
|
public static Account TEST_GetFirstAccount()
|
||||||
=> new AccountsPersister(AccountsSettingsFile).Accounts.GetAll().FirstOrDefault();
|
=> GetAccounts().GetAll().FirstOrDefault();
|
||||||
|
|
||||||
|
public static Accounts GetAccounts()
|
||||||
|
=> new AccountsPersister(AccountsSettingsFile).Accounts;
|
||||||
|
|
||||||
public static string GetIdentityTokensJsonPath(this Account account)
|
public static string GetIdentityTokensJsonPath(this Account account)
|
||||||
=> GetIdentityTokensJsonPath(account.AccountId, account.Locale?.Name);
|
=> GetIdentityTokensJsonPath(account.AccountId, account.Locale?.Name);
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>3.1.12.214</Version>
|
<Version>3.1.12.218</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -54,7 +54,6 @@ namespace LibationLauncher
|
|||||||
var setupDialog = new SetupDialog();
|
var setupDialog = new SetupDialog();
|
||||||
setupDialog.NoQuestionsBtn_Click += (_, __) =>
|
setupDialog.NoQuestionsBtn_Click += (_, __) =>
|
||||||
{
|
{
|
||||||
config.DecryptKey ??= "";
|
|
||||||
config.DownloadsInProgressEnum ??= "WinTemp";
|
config.DownloadsInProgressEnum ??= "WinTemp";
|
||||||
config.DecryptInProgressEnum ??= "WinTemp";
|
config.DecryptInProgressEnum ??= "WinTemp";
|
||||||
config.Books ??= Configuration.AppDir;
|
config.Books ??= Configuration.AppDir;
|
||||||
@ -155,7 +154,6 @@ namespace LibationLauncher
|
|||||||
if (!identity.IsValid)
|
if (!identity.IsValid)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var accountsPersist = new AccountsPersister(AudibleApiStorage.AccountsSettingsFile);
|
|
||||||
var account = new Account(email)
|
var account = new Account(email)
|
||||||
{
|
{
|
||||||
AccountName = $"{email} - {locale.Name}",
|
AccountName = $"{email} - {locale.Name}",
|
||||||
@ -163,7 +161,7 @@ namespace LibationLauncher
|
|||||||
};
|
};
|
||||||
|
|
||||||
// saves to new file
|
// saves to new file
|
||||||
accountsPersist.Accounts.Add(account);
|
AudibleApiStorage.GetAccounts().Add(account);
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
@ -191,17 +189,12 @@ namespace LibationLauncher
|
|||||||
var jObj = JObject.Parse(settingsContents);
|
var jObj = JObject.Parse(settingsContents);
|
||||||
|
|
||||||
var jLocale = jObj.Property("LocaleCountryCode");
|
var jLocale = jObj.Property("LocaleCountryCode");
|
||||||
|
var jDecryptKey = jObj.Property("DecryptKey");
|
||||||
|
|
||||||
//// don't delete old setting until new value is used
|
jDecryptKey?.Remove();
|
||||||
//// remember to remove these from Configuration.cs
|
|
||||||
//var jDecryptKey = jObj.Property("DecryptKey");
|
|
||||||
|
|
||||||
//jDecryptKey?.Remove();
|
|
||||||
jLocale?.Remove();
|
jLocale?.Remove();
|
||||||
|
|
||||||
if (
|
if (jDecryptKey != null || jLocale != null)
|
||||||
//jDecryptKey != null ||
|
|
||||||
jLocale != null)
|
|
||||||
{
|
{
|
||||||
var newContents = jObj.ToString(Formatting.Indented);
|
var newContents = jObj.ToString(Formatting.Indented);
|
||||||
File.WriteAllText(Configuration.Instance.SettingsFilePath, newContents);
|
File.WriteAllText(Configuration.Instance.SettingsFilePath, newContents);
|
||||||
|
|||||||
@ -28,12 +28,9 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.decryptKeyLbl = new System.Windows.Forms.Label();
|
|
||||||
this.decryptKeyTb = new System.Windows.Forms.TextBox();
|
|
||||||
this.booksLocationLbl = new System.Windows.Forms.Label();
|
this.booksLocationLbl = new System.Windows.Forms.Label();
|
||||||
this.booksLocationTb = new System.Windows.Forms.TextBox();
|
this.booksLocationTb = new System.Windows.Forms.TextBox();
|
||||||
this.booksLocationSearchBtn = new System.Windows.Forms.Button();
|
this.booksLocationSearchBtn = new System.Windows.Forms.Button();
|
||||||
this.decryptKeyDescLbl = new System.Windows.Forms.Label();
|
|
||||||
this.booksLocationDescLbl = new System.Windows.Forms.Label();
|
this.booksLocationDescLbl = new System.Windows.Forms.Label();
|
||||||
this.downloadsInProgressGb = new System.Windows.Forms.GroupBox();
|
this.downloadsInProgressGb = new System.Windows.Forms.GroupBox();
|
||||||
this.downloadsInProgressLibationFilesRb = new System.Windows.Forms.RadioButton();
|
this.downloadsInProgressLibationFilesRb = new System.Windows.Forms.RadioButton();
|
||||||
@ -51,22 +48,6 @@
|
|||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// decryptKeyLbl
|
|
||||||
//
|
|
||||||
this.decryptKeyLbl.AutoSize = true;
|
|
||||||
this.decryptKeyLbl.Location = new System.Drawing.Point(6, 22);
|
|
||||||
this.decryptKeyLbl.Name = "decryptKeyLbl";
|
|
||||||
this.decryptKeyLbl.Size = new System.Drawing.Size(64, 13);
|
|
||||||
this.decryptKeyLbl.TabIndex = 0;
|
|
||||||
this.decryptKeyLbl.Text = "Decrypt key";
|
|
||||||
//
|
|
||||||
// decryptKeyTb
|
|
||||||
//
|
|
||||||
this.decryptKeyTb.Location = new System.Drawing.Point(76, 19);
|
|
||||||
this.decryptKeyTb.Name = "decryptKeyTb";
|
|
||||||
this.decryptKeyTb.Size = new System.Drawing.Size(100, 20);
|
|
||||||
this.decryptKeyTb.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// booksLocationLbl
|
// booksLocationLbl
|
||||||
//
|
//
|
||||||
this.booksLocationLbl.AutoSize = true;
|
this.booksLocationLbl.AutoSize = true;
|
||||||
@ -93,15 +74,6 @@
|
|||||||
this.booksLocationSearchBtn.UseVisualStyleBackColor = true;
|
this.booksLocationSearchBtn.UseVisualStyleBackColor = true;
|
||||||
this.booksLocationSearchBtn.Click += new System.EventHandler(this.booksLocationSearchBtn_Click);
|
this.booksLocationSearchBtn.Click += new System.EventHandler(this.booksLocationSearchBtn_Click);
|
||||||
//
|
//
|
||||||
// decryptKeyDescLbl
|
|
||||||
//
|
|
||||||
this.decryptKeyDescLbl.AutoSize = true;
|
|
||||||
this.decryptKeyDescLbl.Location = new System.Drawing.Point(73, 42);
|
|
||||||
this.decryptKeyDescLbl.Name = "decryptKeyDescLbl";
|
|
||||||
this.decryptKeyDescLbl.Size = new System.Drawing.Size(36, 13);
|
|
||||||
this.decryptKeyDescLbl.TabIndex = 2;
|
|
||||||
this.decryptKeyDescLbl.Text = "[desc]";
|
|
||||||
//
|
|
||||||
// booksLocationDescLbl
|
// booksLocationDescLbl
|
||||||
//
|
//
|
||||||
this.booksLocationDescLbl.AutoSize = true;
|
this.booksLocationDescLbl.AutoSize = true;
|
||||||
@ -226,9 +198,6 @@
|
|||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
this.groupBox1.Controls.Add(this.decryptKeyTb);
|
|
||||||
this.groupBox1.Controls.Add(this.decryptKeyLbl);
|
|
||||||
this.groupBox1.Controls.Add(this.decryptKeyDescLbl);
|
|
||||||
this.groupBox1.Controls.Add(this.downloadsInProgressGb);
|
this.groupBox1.Controls.Add(this.downloadsInProgressGb);
|
||||||
this.groupBox1.Controls.Add(this.decryptInProgressGb);
|
this.groupBox1.Controls.Add(this.decryptInProgressGb);
|
||||||
this.groupBox1.Location = new System.Drawing.Point(15, 53);
|
this.groupBox1.Location = new System.Drawing.Point(15, 53);
|
||||||
@ -269,12 +238,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private System.Windows.Forms.Label decryptKeyLbl;
|
|
||||||
private System.Windows.Forms.TextBox decryptKeyTb;
|
|
||||||
private System.Windows.Forms.Label booksLocationLbl;
|
private System.Windows.Forms.Label booksLocationLbl;
|
||||||
private System.Windows.Forms.TextBox booksLocationTb;
|
private System.Windows.Forms.TextBox booksLocationTb;
|
||||||
private System.Windows.Forms.Button booksLocationSearchBtn;
|
private System.Windows.Forms.Button booksLocationSearchBtn;
|
||||||
private System.Windows.Forms.Label decryptKeyDescLbl;
|
|
||||||
private System.Windows.Forms.Label booksLocationDescLbl;
|
private System.Windows.Forms.Label booksLocationDescLbl;
|
||||||
private System.Windows.Forms.GroupBox downloadsInProgressGb;
|
private System.Windows.Forms.GroupBox downloadsInProgressGb;
|
||||||
private System.Windows.Forms.Label downloadsInProgressDescLbl;
|
private System.Windows.Forms.Label downloadsInProgressDescLbl;
|
||||||
|
|||||||
@ -19,8 +19,6 @@ namespace LibationWinForms.Dialogs
|
|||||||
|
|
||||||
private void SettingsDialog_Load(object sender, EventArgs e)
|
private void SettingsDialog_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.decryptKeyTb.Text = config.DecryptKey;
|
|
||||||
this.decryptKeyDescLbl.Text = desc(nameof(config.DecryptKey));
|
|
||||||
this.booksLocationDescLbl.Text = desc(nameof(config.Books));
|
this.booksLocationDescLbl.Text = desc(nameof(config.Books));
|
||||||
this.downloadsInProgressDescLbl.Text = desc(nameof(config.DownloadsInProgressEnum));
|
this.downloadsInProgressDescLbl.Text = desc(nameof(config.DownloadsInProgressEnum));
|
||||||
this.decryptInProgressDescLbl.Text = desc(nameof(config.DecryptInProgressEnum));
|
this.decryptInProgressDescLbl.Text = desc(nameof(config.DecryptInProgressEnum));
|
||||||
@ -73,8 +71,6 @@ namespace LibationWinForms.Dialogs
|
|||||||
|
|
||||||
private void saveBtn_Click(object sender, EventArgs e)
|
private void saveBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
config.DecryptKey = this.decryptKeyTb.Text;
|
|
||||||
|
|
||||||
config.DownloadsInProgressEnum = downloadsInProgressLibationFilesRb.Checked ? "LibationFiles" : "WinTemp";
|
config.DownloadsInProgressEnum = downloadsInProgressLibationFilesRb.Checked ? "LibationFiles" : "WinTemp";
|
||||||
config.DecryptInProgressEnum = decryptInProgressLibationFilesRb.Checked ? "LibationFiles" : "WinTemp";
|
config.DecryptInProgressEnum = decryptInProgressLibationFilesRb.Checked ? "LibationFiles" : "WinTemp";
|
||||||
|
|
||||||
|
|||||||
34
WinFormsDesigner/Dialogs/SettingsDialog.Designer.cs
generated
34
WinFormsDesigner/Dialogs/SettingsDialog.Designer.cs
generated
@ -28,12 +28,9 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.decryptKeyLbl = new System.Windows.Forms.Label();
|
|
||||||
this.decryptKeyTb = new System.Windows.Forms.TextBox();
|
|
||||||
this.booksLocationLbl = new System.Windows.Forms.Label();
|
this.booksLocationLbl = new System.Windows.Forms.Label();
|
||||||
this.booksLocationTb = new System.Windows.Forms.TextBox();
|
this.booksLocationTb = new System.Windows.Forms.TextBox();
|
||||||
this.booksLocationSearchBtn = new System.Windows.Forms.Button();
|
this.booksLocationSearchBtn = new System.Windows.Forms.Button();
|
||||||
this.decryptKeyDescLbl = new System.Windows.Forms.Label();
|
|
||||||
this.booksLocationDescLbl = new System.Windows.Forms.Label();
|
this.booksLocationDescLbl = new System.Windows.Forms.Label();
|
||||||
this.downloadsInProgressGb = new System.Windows.Forms.GroupBox();
|
this.downloadsInProgressGb = new System.Windows.Forms.GroupBox();
|
||||||
this.downloadsInProgressLibationFilesRb = new System.Windows.Forms.RadioButton();
|
this.downloadsInProgressLibationFilesRb = new System.Windows.Forms.RadioButton();
|
||||||
@ -51,22 +48,6 @@
|
|||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// decryptKeyLbl
|
|
||||||
//
|
|
||||||
this.decryptKeyLbl.AutoSize = true;
|
|
||||||
this.decryptKeyLbl.Location = new System.Drawing.Point(6, 22);
|
|
||||||
this.decryptKeyLbl.Name = "decryptKeyLbl";
|
|
||||||
this.decryptKeyLbl.Size = new System.Drawing.Size(64, 13);
|
|
||||||
this.decryptKeyLbl.TabIndex = 0;
|
|
||||||
this.decryptKeyLbl.Text = "Decrypt key";
|
|
||||||
//
|
|
||||||
// decryptKeyTb
|
|
||||||
//
|
|
||||||
this.decryptKeyTb.Location = new System.Drawing.Point(76, 19);
|
|
||||||
this.decryptKeyTb.Name = "decryptKeyTb";
|
|
||||||
this.decryptKeyTb.Size = new System.Drawing.Size(100, 20);
|
|
||||||
this.decryptKeyTb.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// booksLocationLbl
|
// booksLocationLbl
|
||||||
//
|
//
|
||||||
this.booksLocationLbl.AutoSize = true;
|
this.booksLocationLbl.AutoSize = true;
|
||||||
@ -92,15 +73,6 @@
|
|||||||
this.booksLocationSearchBtn.Text = "...";
|
this.booksLocationSearchBtn.Text = "...";
|
||||||
this.booksLocationSearchBtn.UseVisualStyleBackColor = true;
|
this.booksLocationSearchBtn.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// decryptKeyDescLbl
|
|
||||||
//
|
|
||||||
this.decryptKeyDescLbl.AutoSize = true;
|
|
||||||
this.decryptKeyDescLbl.Location = new System.Drawing.Point(73, 42);
|
|
||||||
this.decryptKeyDescLbl.Name = "decryptKeyDescLbl";
|
|
||||||
this.decryptKeyDescLbl.Size = new System.Drawing.Size(36, 13);
|
|
||||||
this.decryptKeyDescLbl.TabIndex = 2;
|
|
||||||
this.decryptKeyDescLbl.Text = "[desc]";
|
|
||||||
//
|
|
||||||
// booksLocationDescLbl
|
// booksLocationDescLbl
|
||||||
//
|
//
|
||||||
this.booksLocationDescLbl.AutoSize = true;
|
this.booksLocationDescLbl.AutoSize = true;
|
||||||
@ -223,9 +195,6 @@
|
|||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
this.groupBox1.Controls.Add(this.decryptKeyTb);
|
|
||||||
this.groupBox1.Controls.Add(this.decryptKeyLbl);
|
|
||||||
this.groupBox1.Controls.Add(this.decryptKeyDescLbl);
|
|
||||||
this.groupBox1.Controls.Add(this.downloadsInProgressGb);
|
this.groupBox1.Controls.Add(this.downloadsInProgressGb);
|
||||||
this.groupBox1.Controls.Add(this.decryptInProgressGb);
|
this.groupBox1.Controls.Add(this.decryptInProgressGb);
|
||||||
this.groupBox1.Location = new System.Drawing.Point(15, 53);
|
this.groupBox1.Location = new System.Drawing.Point(15, 53);
|
||||||
@ -265,12 +234,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private System.Windows.Forms.Label decryptKeyLbl;
|
|
||||||
private System.Windows.Forms.TextBox decryptKeyTb;
|
|
||||||
private System.Windows.Forms.Label booksLocationLbl;
|
private System.Windows.Forms.Label booksLocationLbl;
|
||||||
private System.Windows.Forms.TextBox booksLocationTb;
|
private System.Windows.Forms.TextBox booksLocationTb;
|
||||||
private System.Windows.Forms.Button booksLocationSearchBtn;
|
private System.Windows.Forms.Button booksLocationSearchBtn;
|
||||||
private System.Windows.Forms.Label decryptKeyDescLbl;
|
|
||||||
private System.Windows.Forms.Label booksLocationDescLbl;
|
private System.Windows.Forms.Label booksLocationDescLbl;
|
||||||
private System.Windows.Forms.GroupBox downloadsInProgressGb;
|
private System.Windows.Forms.GroupBox downloadsInProgressGb;
|
||||||
private System.Windows.Forms.Label downloadsInProgressDescLbl;
|
private System.Windows.Forms.Label downloadsInProgressDescLbl;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user