private static async Task <List <ImportItem> > scanAccountAsync(ApiExtended apiExtended, Account account, LibraryOptions.ResponseGroupOptions libraryResponseGroups) { ArgumentValidator.EnsureNotNull(account, nameof(account)); Log.Logger.Information("ImportLibraryAsync. {@DebugInfo}", new { Account = account?.MaskedLogEntry ?? "[null]" }); logTime($"pre scanAccountAsync {account.AccountName}"); var dtoItems = await apiExtended.GetLibraryValidatedAsync(libraryResponseGroups, Configuration.Instance.ImportEpisodes); logTime($"post scanAccountAsync {account.AccountName} qty: {dtoItems.Count}"); return(dtoItems.Select(d => new ImportItem { DtoItem = d, AccountId = account.AccountId, LocaleName = account.Locale?.Name }).ToList()); }
private async void IndexLibraryDialog_Shown(object sender, EventArgs e) { if (_accounts != null && _accounts.Length > 0) { this.label1.Text = (_accounts.Length == 1) ? "Scanning Audible library. This may take a few minutes." : $"Scanning Audible library: {_accounts.Length} accounts. This may take a few minutes per account."; try { (TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.ImportAccountAsync((account) => ApiExtended.CreateAsync(account, new WinformLoginChoiceEager(account)), _accounts); } catch (Exception ex) { MessageBoxAlertAdmin.Show( "Error importing library. Please try again. If this still happens after 2 or 3 tries, stop and contact administrator", "Error importing library", ex); } } this.Close(); }
private async void RemoveBooksDialog_Shown(object sender, EventArgs e) { if (_accounts == null || _accounts.Length == 0) { return; } try { var removedBooks = await LibraryCommands.FindInactiveBooks((account) => ApiExtended.CreateAsync(account, new WinformLoginChoiceEager(account)), _libraryBooks, _accounts); var removable = _removableGridEntries.Where(rge => removedBooks.Any(rb => rb.Book.AudibleProductId == rge.AudibleProductId)).ToList(); if (!removable.Any()) { return; } foreach (var r in removable) { r.Remove = true; } UpdateSelection(); } catch (Exception ex) { MessageBoxAlertAdmin.Show( "Error scanning library. You may still manually select books to remove from Libation's library.", "Error scanning library", ex); } finally { _dataGridView.Enabled = true; } }
protected override async Task ProcessAsync() { var accounts = getAccounts(); if (!accounts.Any()) { Console.WriteLine("No accounts. Exiting."); Environment.ExitCode = (int)ExitCode.RunTimeError; return; } var _accounts = accounts.ToArray(); var intro = (_accounts.Length == 1) ? "Scanning Audible library. This may take a few minutes." : $"Scanning Audible library: {_accounts.Length} accounts. This may take a few minutes per account."; Console.WriteLine(intro); var(TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.ImportAccountAsync((a) => ApiExtended.CreateAsync(a), _accounts); Console.WriteLine("Scan complete."); Console.WriteLine($"Total processed: {TotalBooksProcessed}\r\nNew: {NewBooksAdded}"); }