diff --git a/Source/ApplicationServices/LibraryCommands.cs b/Source/ApplicationServices/LibraryCommands.cs index 3bbf93c5..3ceab15b 100644 --- a/Source/ApplicationServices/LibraryCommands.cs +++ b/Source/ApplicationServices/LibraryCommands.cs @@ -33,18 +33,20 @@ namespace ApplicationServices //These are the minimum response groups required for the //library scanner to pass all validation and filtering. - var libraryResponseGroups = - LibraryOptions.ResponseGroupOptions.ProductAttrs | - LibraryOptions.ResponseGroupOptions.ProductDesc | - LibraryOptions.ResponseGroupOptions.Relationships; - - if (accounts is null || accounts.Length == 0) + var libraryOptions = new LibraryOptions + { + ResponseGroups + = LibraryOptions.ResponseGroupOptions.ProductAttrs + | LibraryOptions.ResponseGroupOptions.ProductDesc + | LibraryOptions.ResponseGroupOptions.Relationships + }; + if (accounts is null || accounts.Length == 0) return new List(); try { logTime($"pre {nameof(scanAccountsAsync)} all"); - var libraryItems = await scanAccountsAsync(apiExtendedfunc, accounts, libraryResponseGroups); + var libraryItems = await scanAccountsAsync(apiExtendedfunc, accounts, libraryOptions); logTime($"post {nameof(scanAccountsAsync)} all"); var totalCount = libraryItems.Count; @@ -102,7 +104,12 @@ namespace ApplicationServices } logTime($"pre {nameof(scanAccountsAsync)} all"); - var importItems = await scanAccountsAsync(apiExtendedfunc, accounts, LibraryOptions.ResponseGroupOptions.ALL_OPTIONS); + var libraryOptions = new LibraryOptions + { + ResponseGroups = LibraryOptions.ResponseGroupOptions.ALL_OPTIONS, + ImageSizes = LibraryOptions.ImageSizeOptions._500 | LibraryOptions.ImageSizeOptions._1215 + }; + var importItems = await scanAccountsAsync(apiExtendedfunc, accounts, libraryOptions); logTime($"post {nameof(scanAccountsAsync)} all"); var totalCount = importItems.Count; @@ -150,7 +157,7 @@ namespace ApplicationServices } } - private static async Task> scanAccountsAsync(Func> apiExtendedfunc, Account[] accounts, LibraryOptions.ResponseGroupOptions libraryResponseGroups) + private static async Task> scanAccountsAsync(Func> apiExtendedfunc, Account[] accounts, LibraryOptions libraryOptions) { var tasks = new List>>(); foreach (var account in accounts) @@ -159,7 +166,7 @@ namespace ApplicationServices var apiExtended = await apiExtendedfunc(account); // add scanAccountAsync as a TASK: do not await - tasks.Add(scanAccountAsync(apiExtended, account, libraryResponseGroups)); + tasks.Add(scanAccountAsync(apiExtended, account, libraryOptions)); } // import library in parallel @@ -168,7 +175,7 @@ namespace ApplicationServices return importItems; } - private static async Task> scanAccountAsync(ApiExtended apiExtended, Account account, LibraryOptions.ResponseGroupOptions libraryResponseGroups) + private static async Task> scanAccountAsync(ApiExtended apiExtended, Account account, LibraryOptions libraryOptions) { ArgumentValidator.EnsureNotNull(account, nameof(account)); @@ -179,7 +186,7 @@ namespace ApplicationServices logTime($"pre scanAccountAsync {account.AccountName}"); - var dtoItems = await apiExtended.GetLibraryValidatedAsync(libraryResponseGroups, Configuration.Instance.ImportEpisodes); + var dtoItems = await apiExtended.GetLibraryValidatedAsync(libraryOptions, Configuration.Instance.ImportEpisodes); logTime($"post scanAccountAsync {account.AccountName} qty: {dtoItems.Count}"); diff --git a/Source/AudibleUtilities/ApiExtended.cs b/Source/AudibleUtilities/ApiExtended.cs index 512949ef..5a00c9a7 100644 --- a/Source/AudibleUtilities/ApiExtended.cs +++ b/Source/AudibleUtilities/ApiExtended.cs @@ -106,16 +106,16 @@ namespace AudibleUtilities // 2 retries == 3 total .RetryAsync(2); - public Task> GetLibraryValidatedAsync(LibraryOptions.ResponseGroupOptions responseGroups = LibraryOptions.ResponseGroupOptions.ALL_OPTIONS, bool importEpisodes = true) + public Task> GetLibraryValidatedAsync(LibraryOptions libraryOptions, 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 not 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, importEpisodes)); + return policy.ExecuteAsync(() => getItemsAsync(libraryOptions, importEpisodes)); } - private async Task> getItemsAsync(LibraryOptions.ResponseGroupOptions responseGroups, bool importEpisodes) + private async Task> getItemsAsync(LibraryOptions libraryOptions, bool importEpisodes) { var items = new List(); #if DEBUG @@ -131,7 +131,7 @@ namespace AudibleUtilities Serilog.Log.Logger.Debug("Begin initial library scan"); if (!items.Any()) - items = await Api.GetAllLibraryItemsAsync(responseGroups); + items = await Api.GetAllLibraryItemsAsync(libraryOptions); Serilog.Log.Logger.Debug("Initial library scan complete. Begin episode scan"); diff --git a/Source/AudibleUtilities/AudibleUtilities.csproj b/Source/AudibleUtilities/AudibleUtilities.csproj index 1b933a47..b96dcfe2 100644 --- a/Source/AudibleUtilities/AudibleUtilities.csproj +++ b/Source/AudibleUtilities/AudibleUtilities.csproj @@ -5,7 +5,7 @@ - +