// selectively remove books from all accounts private void removeAllAccountsToolStripMenuItem_Click(object sender, EventArgs e) { using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var allAccounts = persister.AccountsSettings.GetAll(); scanLibrariesRemovedBooks(allAccounts.ToArray()); }
private void saveBtn_Click(object sender, EventArgs e) { try { if (!inputIsValid()) { return; } // without transaction, accounts persister will write ANY EDIT immediately to file using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); persister.BeginTransation(); persist(persister.AccountsSettings); persister.CommitTransation(); _parent.RefreshImportMenu(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBoxAlertAdmin.Show("Error attempting to save accounts", "Error saving accounts", ex); } }
private void scanLibraryOfAllAccountsToolStripMenuItem_Click(object sender, EventArgs e) { using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var allAccounts = persister.AccountsSettings.GetAll(); scanLibraries(allAccounts); }
private void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e) { using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var firstAccount = persister.AccountsSettings.GetAll().FirstOrDefault(); scanLibraries(firstAccount); }
/// <summary>most migrations go in here</summary> public static void RunPostConfigMigrations(Configuration config) { AudibleApiStorage.EnsureAccountsSettingsFileExists(); PopulateMissingConfigValues(config); // // migrations go below here // Migrations.migrate_to_v6_5_2(config); }
private void ScanAccountsDialog_Load(object sender, EventArgs e) { using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var accounts = persister.AccountsSettings.Accounts; foreach (var account in accounts) { var item = new listItem { Account = account, Text = $"{account.AccountName} ({account.AccountId} - {account.Locale.Name})" }; this.accountsClb.Items.Add(item, account.LibraryScan); } }
public void RefreshImportMenu(object _ = null, EventArgs __ = null) { using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var count = persister.AccountsSettings.Accounts.Count; noAccountsYetAddAccountToolStripMenuItem.Visible = count == 0; scanLibraryToolStripMenuItem.Visible = count == 1; scanLibraryOfAllAccountsToolStripMenuItem.Visible = count > 1; scanLibraryOfSomeAccountsToolStripMenuItem.Visible = count > 1; removeLibraryBooksToolStripMenuItem.Visible = count != 0; removeSomeAccountsToolStripMenuItem.Visible = count > 1; removeAllAccountsToolStripMenuItem.Visible = count > 1; }
private void removeLibraryBooksToolStripMenuItem_Click(object sender, EventArgs e) { // if 0 accounts, this will not be visible // if 1 account, run scanLibrariesRemovedBooks() on this account // if multiple accounts, another menu set will open. do not run scanLibrariesRemovedBooks() using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var accounts = persister.AccountsSettings.GetAll(); if (accounts.Count != 1) { return; } var firstAccount = accounts.Single(); scanLibrariesRemovedBooks(firstAccount); }
private async Task <string> aaxToM4bConverterDecrypt(string aaxFilename, LibraryBook libraryBook) { DecryptBegin?.Invoke(this, $"Begin decrypting {aaxFilename}"); try { using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var account = persister .AccountsSettings .GetAccount(libraryBook.Account, libraryBook.Book.Locale); var converter = await AaxToM4bConverter.CreateAsync(aaxFilename, account.DecryptKey); converter.AppName = "Libation"; TitleDiscovered?.Invoke(this, converter.tags.title); AuthorsDiscovered?.Invoke(this, converter.tags.author); NarratorsDiscovered?.Invoke(this, converter.tags.narrator); CoverImageFilepathDiscovered?.Invoke(this, converter.coverBytes); // override default which was set in CreateAsync var proposedOutputFile = Path.Combine(AudibleFileStorage.DecryptInProgress, $"[{libraryBook.Book.AudibleProductId}].m4b"); converter.SetOutputFilename(proposedOutputFile); converter.DecryptProgressUpdate += (s, progress) => UpdateProgress?.Invoke(this, progress); // REAL WORK DONE HERE var success = await Task.Run(() => converter.Run()); // decrypt failed if (!success) { return(null); } account.DecryptKey = converter.decryptKey; return(converter.outputFileName); } finally { DecryptCompleted?.Invoke(this, $"Completed decrypting {aaxFilename}"); } }
private Account[] getAccounts() { using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var accounts = persister.AccountsSettings.GetAll().ToArray(); if (!AccountNicknames.Any()) { return(accounts); } var found = accounts.Where(acct => AccountNicknames.Contains(acct.AccountName)).ToArray(); var notFound = AccountNicknames.Except(found.Select(f => f.AccountName)).ToArray(); // no accounts found. do not continue if (!found.Any()) { Console.WriteLine("Accounts not found:"); foreach (var nf in notFound) { Console.WriteLine($"- {nf}"); } return(found); } // some accounts not found. continue after message if (notFound.Any()) { Console.WriteLine("Accounts found:"); foreach (var f in found) { Console.WriteLine($"- {f}"); } Console.WriteLine("Accounts not found:"); foreach (var nf in notFound) { Console.WriteLine($"- {nf}"); } } // else: all accounts area found. silently continue return(found); }
private void saveBtn_Click(object sender, EventArgs e) { try { // without transaction, accounts persister will write ANY EDIT immediately to file using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); persister.BeginTransation(); persist(persister.AccountsSettings); persister.CommitTransation(); _parent.RefreshImportMenu(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); createSettings(); AudibleApiStorage.EnsureAccountsSettingsFileExists(); migrate_to_v4_0_0(); migrate_to_v4_0_3(); // add setting for whether to delete/retain aax ensureLoggingConfig(); ensureSerilogConfig(); configureLogging(); checkForUpdate(); logStartupState(); Application.Run(new Form1()); }
private void populateGridValues() { // WARNING: accounts persister will write ANY EDIT to object immediately to file // here: copy strings and dispose of persister // only persist in 'save' step using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); var accounts = persister.AccountsSettings.Accounts; if (!accounts.Any()) { return; } foreach (var account in accounts) { dataGridView1.Rows.Add( "X", account.LibraryScan, account.AccountId, account.Locale.Name, account.AccountName); } }
static void Main() { //// uncomment to see Console. MUST be called before anything writes to Console. Might only work from VS //AllocConsole(); Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // must occur before access to Configuration instance migrate_to_v5_2_0__pre_config(); //***********************************************// // // // do not use Configuration before this line // // // //***********************************************// var config = Configuration.Instance; createSettings(config); AudibleApiStorage.EnsureAccountsSettingsFileExists(); migrate_to_v5_0_0(config); migrate_to_v5_2_0__post_config(config); ensureSerilogConfig(config); configureLogging(config); logStartupState(config); checkForUpdate(config); Application.Run(new Form1()); }