diff --git a/AppScaffolding/AppScaffolding.csproj b/AppScaffolding/AppScaffolding.csproj index a60462c8..886373bb 100644 --- a/AppScaffolding/AppScaffolding.csproj +++ b/AppScaffolding/AppScaffolding.csproj @@ -3,7 +3,7 @@ net5.0 - 6.1.3.1 + 6.1.4.1 diff --git a/AppScaffolding/LibationScaffolding.cs b/AppScaffolding/LibationScaffolding.cs index ad94a8ef..1a055617 100644 --- a/AppScaffolding/LibationScaffolding.cs +++ b/AppScaffolding/LibationScaffolding.cs @@ -328,11 +328,14 @@ namespace AppScaffolding config.BadBook = Configuration.BadBookAction.Ask; } - // add config.DownloadEpisodes + // add config.DownloadEpisodes , config.ImportEpisodes public static void migrate_to_v6_1_2(Configuration config) { if (!config.Exists(nameof(config.DownloadEpisodes))) config.DownloadEpisodes = true; + + if (!config.Exists(nameof(config.ImportEpisodes))) + config.ImportEpisodes = true; } } } diff --git a/ApplicationServices/LibraryCommands.cs b/ApplicationServices/LibraryCommands.cs index 28df51b2..c8fc3f54 100644 --- a/ApplicationServices/LibraryCommands.cs +++ b/ApplicationServices/LibraryCommands.cs @@ -14,15 +14,13 @@ namespace ApplicationServices { public static class LibraryCommands { - private static LibraryOptions.ResponseGroupOptions LibraryResponseGroups = LibraryOptions.ResponseGroupOptions.ALL_OPTIONS; - public static async Task> FindInactiveBooks(Func> apiExtendedfunc, List existingLibrary, params Account[] accounts) { logRestart(); //These are the minimum response groups required for the //library scanner to pass all validation and filtering. - LibraryResponseGroups = + var libraryResponseGroups = LibraryOptions.ResponseGroupOptions.ProductAttrs | LibraryOptions.ResponseGroupOptions.ProductDesc | LibraryOptions.ResponseGroupOptions.Relationships; @@ -33,7 +31,7 @@ namespace ApplicationServices try { logTime($"pre {nameof(scanAccountsAsync)} all"); - var libraryItems = await scanAccountsAsync(apiExtendedfunc, accounts); + var libraryItems = await scanAccountsAsync(apiExtendedfunc, accounts, libraryResponseGroups); logTime($"post {nameof(scanAccountsAsync)} all"); var totalCount = libraryItems.Count; @@ -68,7 +66,6 @@ namespace ApplicationServices } finally { - LibraryResponseGroups = LibraryOptions.ResponseGroupOptions.ALL_OPTIONS; stop(); var putBreakPointHere = logOutput; } @@ -85,7 +82,7 @@ namespace ApplicationServices try { logTime($"pre {nameof(scanAccountsAsync)} all"); - var importItems = await scanAccountsAsync(apiExtendedfunc, accounts); + var importItems = await scanAccountsAsync(apiExtendedfunc, accounts, LibraryOptions.ResponseGroupOptions.ALL_OPTIONS); logTime($"post {nameof(scanAccountsAsync)} all"); var totalCount = importItems.Count; @@ -129,7 +126,7 @@ namespace ApplicationServices } } - private static async Task> scanAccountsAsync(Func> apiExtendedfunc, Account[] accounts) + private static async Task> scanAccountsAsync(Func> apiExtendedfunc, Account[] accounts, LibraryOptions.ResponseGroupOptions libraryResponseGroups) { var tasks = new List>>(); foreach (var account in accounts) @@ -138,7 +135,7 @@ namespace ApplicationServices var apiExtended = await apiExtendedfunc(account); // add scanAccountAsync as a TASK: do not await - tasks.Add(scanAccountAsync(apiExtended, account)); + tasks.Add(scanAccountAsync(apiExtended, account, libraryResponseGroups)); } // import library in parallel @@ -147,7 +144,7 @@ namespace ApplicationServices return importItems; } - private static async Task> scanAccountAsync(ApiExtended apiExtended, Account account) + private static async Task> scanAccountAsync(ApiExtended apiExtended, Account account, LibraryOptions.ResponseGroupOptions libraryResponseGroups) { ArgumentValidator.EnsureNotNull(account, nameof(account)); @@ -158,7 +155,7 @@ namespace ApplicationServices logTime($"pre scanAccountAsync {account.AccountName}"); - var dtoItems = await apiExtended.GetLibraryValidatedAsync(LibraryResponseGroups); + var dtoItems = await apiExtended.GetLibraryValidatedAsync(libraryResponseGroups, FileManager.Configuration.Instance.ImportEpisodes); logTime($"post scanAccountAsync {account.AccountName} qty: {dtoItems.Count}"); diff --git a/FileManager/Configuration.cs b/FileManager/Configuration.cs index 69cd65b5..0c1ec471 100644 --- a/FileManager/Configuration.cs +++ b/FileManager/Configuration.cs @@ -125,7 +125,14 @@ namespace FileManager set => persistentDictionary.SetString(nameof(BadBook), value.ToString()); } - [Description("Download episodes? (eg: podcasts)")] + [Description("Import episodes? (eg: podcasts) When unchecked, episodes will not be imported into Libation.")] + public bool ImportEpisodes + { + get => persistentDictionary.GetNonString(nameof(ImportEpisodes)); + set => persistentDictionary.SetNonString(nameof(ImportEpisodes), value); + } + + [Description("Download episodes? (eg: podcasts). When unchecked, episodes already in Libation will not be downloaded.")] public bool DownloadEpisodes { get => persistentDictionary.GetNonString(nameof(DownloadEpisodes)); diff --git a/InternalUtilities/ApiExtended.cs b/InternalUtilities/ApiExtended.cs index a0ae12b1..d67673ef 100644 --- a/InternalUtilities/ApiExtended.cs +++ b/InternalUtilities/ApiExtended.cs @@ -106,16 +106,16 @@ namespace InternalUtilities // 2 retries == 3 total .RetryAsync(2); - public Task> GetLibraryValidatedAsync(LibraryOptions.ResponseGroupOptions responseGroups = LibraryOptions.ResponseGroupOptions.ALL_OPTIONS) + public Task> GetLibraryValidatedAsync(LibraryOptions.ResponseGroupOptions responseGroups = LibraryOptions.ResponseGroupOptions.ALL_OPTIONS, bool importEpisodes = true) { // bug on audible's side. the 1st time after a long absence, a query to get library will return without titles or authors. a subsequent identical query will be successful. this is true whether or tokens are refreshed // worse, this 1st dummy call doesn't seem to help: // var page = await api.GetLibraryAsync(new AudibleApi.LibraryOptions { NumberOfResultPerPage = 1, PageNumber = 1, PurchasedAfter = DateTime.Now.AddYears(-20), ResponseGroups = AudibleApi.LibraryOptions.ResponseGroupOptions.ALL_OPTIONS }); // i don't want to incur the cost of making a full dummy call every time because it fails sometimes - return policy.ExecuteAsync(() => getItemsAsync(responseGroups)); + return policy.ExecuteAsync(() => getItemsAsync(responseGroups, importEpisodes)); } - private async Task> getItemsAsync(LibraryOptions.ResponseGroupOptions responseGroups) + private async Task> getItemsAsync(LibraryOptions.ResponseGroupOptions responseGroups, bool importEpisodes) { var items = new List(); #if DEBUG @@ -130,7 +130,8 @@ namespace InternalUtilities if (!items.Any()) items = await Api.GetAllLibraryItemsAsync(responseGroups); - await manageEpisodesAsync(items); + if (importEpisodes) + await manageEpisodesAsync(items); #if DEBUG //System.IO.File.WriteAllText(library_json, AudibleApi.Common.Converter.ToJson(items)); diff --git a/LibationWinForms/Dialogs/SettingsDialog.Designer.cs b/LibationWinForms/Dialogs/SettingsDialog.Designer.cs index 854dd3a2..d10cef34 100644 --- a/LibationWinForms/Dialogs/SettingsDialog.Designer.cs +++ b/LibationWinForms/Dialogs/SettingsDialog.Designer.cs @@ -33,6 +33,8 @@ this.saveBtn = new System.Windows.Forms.Button(); this.cancelBtn = new System.Windows.Forms.Button(); this.advancedSettingsGb = new System.Windows.Forms.GroupBox(); + this.importEpisodesCb = new System.Windows.Forms.CheckBox(); + this.downloadEpisodesCb = new System.Windows.Forms.CheckBox(); this.badBookGb = new System.Windows.Forms.GroupBox(); this.badBookIgnoreRb = new System.Windows.Forms.RadioButton(); this.badBookRetryRb = new System.Windows.Forms.RadioButton(); @@ -48,7 +50,6 @@ this.booksGb = new System.Windows.Forms.GroupBox(); this.loggingLevelLbl = new System.Windows.Forms.Label(); this.loggingLevelCb = new System.Windows.Forms.ComboBox(); - this.downloadEpisodesCb = new System.Windows.Forms.CheckBox(); this.advancedSettingsGb.SuspendLayout(); this.badBookGb.SuspendLayout(); this.decryptAndConvertGb.SuspendLayout(); @@ -68,21 +69,21 @@ // inProgressDescLbl // this.inProgressDescLbl.AutoSize = true; - this.inProgressDescLbl.Location = new System.Drawing.Point(8, 174); + this.inProgressDescLbl.Location = new System.Drawing.Point(8, 199); this.inProgressDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.inProgressDescLbl.Name = "inProgressDescLbl"; this.inProgressDescLbl.Size = new System.Drawing.Size(43, 45); - this.inProgressDescLbl.TabIndex = 15; + this.inProgressDescLbl.TabIndex = 18; this.inProgressDescLbl.Text = "[desc]\r\n[line 2]\r\n[line 3]"; // // saveBtn // this.saveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.saveBtn.Location = new System.Drawing.Point(714, 470); + this.saveBtn.Location = new System.Drawing.Point(714, 496); this.saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.saveBtn.Name = "saveBtn"; this.saveBtn.Size = new System.Drawing.Size(88, 27); - this.saveBtn.TabIndex = 17; + this.saveBtn.TabIndex = 98; this.saveBtn.Text = "Save"; this.saveBtn.UseVisualStyleBackColor = true; this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click); @@ -91,11 +92,11 @@ // this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelBtn.Location = new System.Drawing.Point(832, 470); + this.cancelBtn.Location = new System.Drawing.Point(832, 496); this.cancelBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cancelBtn.Name = "cancelBtn"; this.cancelBtn.Size = new System.Drawing.Size(88, 27); - this.cancelBtn.TabIndex = 18; + this.cancelBtn.TabIndex = 99; this.cancelBtn.Text = "Cancel"; this.cancelBtn.UseVisualStyleBackColor = true; this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click); @@ -105,6 +106,7 @@ this.advancedSettingsGb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.advancedSettingsGb.Controls.Add(this.importEpisodesCb); this.advancedSettingsGb.Controls.Add(this.downloadEpisodesCb); this.advancedSettingsGb.Controls.Add(this.badBookGb); this.advancedSettingsGb.Controls.Add(this.decryptAndConvertGb); @@ -114,21 +116,41 @@ this.advancedSettingsGb.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.advancedSettingsGb.Name = "advancedSettingsGb"; this.advancedSettingsGb.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.advancedSettingsGb.Size = new System.Drawing.Size(908, 283); + this.advancedSettingsGb.Size = new System.Drawing.Size(908, 309); this.advancedSettingsGb.TabIndex = 6; this.advancedSettingsGb.TabStop = false; this.advancedSettingsGb.Text = "Advanced settings for control freaks"; // + // importEpisodesCb + // + this.importEpisodesCb.AutoSize = true; + this.importEpisodesCb.Location = new System.Drawing.Point(7, 22); + this.importEpisodesCb.Name = "importEpisodesCb"; + this.importEpisodesCb.Size = new System.Drawing.Size(146, 19); + this.importEpisodesCb.TabIndex = 7; + this.importEpisodesCb.Text = "[import episodes desc]"; + this.importEpisodesCb.UseVisualStyleBackColor = true; + // + // downloadEpisodesCb + // + this.downloadEpisodesCb.AutoSize = true; + this.downloadEpisodesCb.Location = new System.Drawing.Point(7, 47); + this.downloadEpisodesCb.Name = "downloadEpisodesCb"; + this.downloadEpisodesCb.Size = new System.Drawing.Size(163, 19); + this.downloadEpisodesCb.TabIndex = 8; + this.downloadEpisodesCb.Text = "[download episodes desc]"; + this.downloadEpisodesCb.UseVisualStyleBackColor = true; + // // badBookGb // this.badBookGb.Controls.Add(this.badBookIgnoreRb); this.badBookGb.Controls.Add(this.badBookRetryRb); this.badBookGb.Controls.Add(this.badBookAbortRb); this.badBookGb.Controls.Add(this.badBookAskRb); - this.badBookGb.Location = new System.Drawing.Point(372, 47); + this.badBookGb.Location = new System.Drawing.Point(372, 72); this.badBookGb.Name = "badBookGb"; this.badBookGb.Size = new System.Drawing.Size(529, 124); - this.badBookGb.TabIndex = 11; + this.badBookGb.TabIndex = 13; this.badBookGb.TabStop = false; this.badBookGb.Text = "[bad book desc]"; // @@ -138,7 +160,7 @@ this.badBookIgnoreRb.Location = new System.Drawing.Point(6, 97); this.badBookIgnoreRb.Name = "badBookIgnoreRb"; this.badBookIgnoreRb.Size = new System.Drawing.Size(94, 19); - this.badBookIgnoreRb.TabIndex = 15; + this.badBookIgnoreRb.TabIndex = 17; this.badBookIgnoreRb.TabStop = true; this.badBookIgnoreRb.Text = "[ignore desc]"; this.badBookIgnoreRb.UseVisualStyleBackColor = true; @@ -149,7 +171,7 @@ this.badBookRetryRb.Location = new System.Drawing.Point(6, 72); this.badBookRetryRb.Name = "badBookRetryRb"; this.badBookRetryRb.Size = new System.Drawing.Size(84, 19); - this.badBookRetryRb.TabIndex = 14; + this.badBookRetryRb.TabIndex = 16; this.badBookRetryRb.TabStop = true; this.badBookRetryRb.Text = "[retry desc]"; this.badBookRetryRb.UseVisualStyleBackColor = true; @@ -160,7 +182,7 @@ this.badBookAbortRb.Location = new System.Drawing.Point(6, 47); this.badBookAbortRb.Name = "badBookAbortRb"; this.badBookAbortRb.Size = new System.Drawing.Size(88, 19); - this.badBookAbortRb.TabIndex = 13; + this.badBookAbortRb.TabIndex = 15; this.badBookAbortRb.TabStop = true; this.badBookAbortRb.Text = "[abort desc]"; this.badBookAbortRb.UseVisualStyleBackColor = true; @@ -171,7 +193,7 @@ this.badBookAskRb.Location = new System.Drawing.Point(6, 22); this.badBookAskRb.Name = "badBookAskRb"; this.badBookAskRb.Size = new System.Drawing.Size(77, 19); - this.badBookAskRb.TabIndex = 12; + this.badBookAskRb.TabIndex = 14; this.badBookAskRb.TabStop = true; this.badBookAskRb.Text = "[ask desc]"; this.badBookAskRb.UseVisualStyleBackColor = true; @@ -181,10 +203,10 @@ this.decryptAndConvertGb.Controls.Add(this.allowLibationFixupCbox); this.decryptAndConvertGb.Controls.Add(this.convertLossyRb); this.decryptAndConvertGb.Controls.Add(this.convertLosslessRb); - this.decryptAndConvertGb.Location = new System.Drawing.Point(8, 47); + this.decryptAndConvertGb.Location = new System.Drawing.Point(7, 72); this.decryptAndConvertGb.Name = "decryptAndConvertGb"; this.decryptAndConvertGb.Size = new System.Drawing.Size(359, 124); - this.decryptAndConvertGb.TabIndex = 7; + this.decryptAndConvertGb.TabIndex = 9; this.decryptAndConvertGb.TabStop = false; this.decryptAndConvertGb.Text = "Decrypt and convert"; // @@ -196,7 +218,7 @@ this.allowLibationFixupCbox.Location = new System.Drawing.Point(6, 22); this.allowLibationFixupCbox.Name = "allowLibationFixupCbox"; this.allowLibationFixupCbox.Size = new System.Drawing.Size(262, 19); - this.allowLibationFixupCbox.TabIndex = 8; + this.allowLibationFixupCbox.TabIndex = 10; this.allowLibationFixupCbox.Text = "Allow Libation to fix up audiobook metadata"; this.allowLibationFixupCbox.UseVisualStyleBackColor = true; this.allowLibationFixupCbox.CheckedChanged += new System.EventHandler(this.allowLibationFixupCbox_CheckedChanged); @@ -207,7 +229,7 @@ this.convertLossyRb.Location = new System.Drawing.Point(6, 81); this.convertLossyRb.Name = "convertLossyRb"; this.convertLossyRb.Size = new System.Drawing.Size(329, 19); - this.convertLossyRb.TabIndex = 10; + this.convertLossyRb.TabIndex = 12; this.convertLossyRb.Text = "Download my books as .MP3 files (transcode if necessary)"; this.convertLossyRb.UseVisualStyleBackColor = true; // @@ -218,7 +240,7 @@ this.convertLosslessRb.Location = new System.Drawing.Point(6, 56); this.convertLosslessRb.Name = "convertLosslessRb"; this.convertLosslessRb.Size = new System.Drawing.Size(335, 19); - this.convertLosslessRb.TabIndex = 9; + this.convertLosslessRb.TabIndex = 11; this.convertLosslessRb.TabStop = true; this.convertLosslessRb.Text = "Download my books in the original audio format (Lossless)"; this.convertLosslessRb.UseVisualStyleBackColor = true; @@ -227,10 +249,10 @@ // this.inProgressSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.inProgressSelectControl.Location = new System.Drawing.Point(7, 222); + this.inProgressSelectControl.Location = new System.Drawing.Point(7, 247); this.inProgressSelectControl.Name = "inProgressSelectControl"; this.inProgressSelectControl.Size = new System.Drawing.Size(552, 52); - this.inProgressSelectControl.TabIndex = 16; + this.inProgressSelectControl.TabIndex = 19; // // logsBtn // @@ -282,23 +304,13 @@ this.loggingLevelCb.Size = new System.Drawing.Size(129, 23); this.loggingLevelCb.TabIndex = 4; // - // downloadEpisodesCb - // - this.downloadEpisodesCb.AutoSize = true; - this.downloadEpisodesCb.Location = new System.Drawing.Point(8, 22); - this.downloadEpisodesCb.Name = "downloadEpisodesCb"; - this.downloadEpisodesCb.Size = new System.Drawing.Size(163, 19); - this.downloadEpisodesCb.TabIndex = 17; - this.downloadEpisodesCb.Text = "[download episodes desc]"; - this.downloadEpisodesCb.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, 513); + this.ClientSize = new System.Drawing.Size(933, 539); this.Controls.Add(this.logsBtn); this.Controls.Add(this.loggingLevelCb); this.Controls.Add(this.loggingLevelLbl); @@ -347,5 +359,6 @@ private System.Windows.Forms.RadioButton badBookAskRb; private System.Windows.Forms.RadioButton badBookIgnoreRb; private System.Windows.Forms.CheckBox downloadEpisodesCb; + private System.Windows.Forms.CheckBox importEpisodesCb; } } \ No newline at end of file diff --git a/LibationWinForms/Dialogs/SettingsDialog.cs b/LibationWinForms/Dialogs/SettingsDialog.cs index 3e234c43..3e2434e7 100644 --- a/LibationWinForms/Dialogs/SettingsDialog.cs +++ b/LibationWinForms/Dialogs/SettingsDialog.cs @@ -26,6 +26,7 @@ namespace LibationWinForms.Dialogs loggingLevelCb.SelectedItem = config.LogLevel; } + this.importEpisodesCb.Text = desc(nameof(config.ImportEpisodes)); this.downloadEpisodesCb.Text = desc(nameof(config.DownloadEpisodes)); this.booksLocationDescLbl.Text = desc(nameof(config.Books)); this.inProgressDescLbl.Text = desc(nameof(config.InProgress)); @@ -42,6 +43,7 @@ namespace LibationWinForms.Dialogs "Books"); booksSelectControl.SelectDirectory(config.Books); + importEpisodesCb.Checked = config.ImportEpisodes; downloadEpisodesCb.Checked = config.DownloadEpisodes; allowLibationFixupCbox.Checked = config.AllowLibationFixup; convertLosslessRb.Checked = !config.DecryptToLossy; @@ -123,6 +125,7 @@ namespace LibationWinForms.Dialogs MessageBoxVerboseLoggingWarning.ShowIfTrue(); } + config.ImportEpisodes = importEpisodesCb.Checked; config.DownloadEpisodes = downloadEpisodesCb.Checked; config.AllowLibationFixup = allowLibationFixupCbox.Checked; config.DecryptToLossy = convertLossyRb.Checked;