From 22548dc8aefbd1427fefea0b1647d3b15c64840e Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Wed, 29 Sep 2021 10:00:04 -0400 Subject: [PATCH] bug fix: if not importing episodes, remember to remove parents from import list --- AppScaffolding/AppScaffolding.csproj | 2 +- InternalUtilities/ApiExtended.cs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/AppScaffolding/AppScaffolding.csproj b/AppScaffolding/AppScaffolding.csproj index 7ba04b8c..6e752fcc 100644 --- a/AppScaffolding/AppScaffolding.csproj +++ b/AppScaffolding/AppScaffolding.csproj @@ -3,7 +3,7 @@ net5.0 - 6.1.5.1 + 6.1.6.1 diff --git a/InternalUtilities/ApiExtended.cs b/InternalUtilities/ApiExtended.cs index d67673ef..56c4d055 100644 --- a/InternalUtilities/ApiExtended.cs +++ b/InternalUtilities/ApiExtended.cs @@ -108,7 +108,7 @@ namespace InternalUtilities 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 + // 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 @@ -130,8 +130,7 @@ namespace InternalUtilities if (!items.Any()) items = await Api.GetAllLibraryItemsAsync(responseGroups); - if (importEpisodes) - await manageEpisodesAsync(items); + await manageEpisodesAsync(items, importEpisodes); #if DEBUG //System.IO.File.WriteAllText(library_json, AudibleApi.Common.Converter.ToJson(items)); @@ -150,7 +149,7 @@ namespace InternalUtilities } #region episodes and podcasts - private async Task manageEpisodesAsync(List items) + private async Task manageEpisodesAsync(List items, bool importEpisodes) { // add podcasts and episodes to list. If fail, don't let it de-rail the rest of the import try @@ -171,10 +170,13 @@ namespace InternalUtilities // also must happen before processing children because children abuses this flag items.RemoveAll(i => i.IsEpisodes); - // add children - var children = await getEpisodesAsync(parents); - Serilog.Log.Logger.Information($"{children.Count} episodes of shows/podcasts found"); - items.AddRange(children); + if (importEpisodes) + { + // add children + var children = await getEpisodesAsync(parents); + Serilog.Log.Logger.Information($"{children.Count} episodes of shows/podcasts found"); + items.AddRange(children); + } } catch (Exception ex) {