From c54c45df33c658947372799fca1093e54110bdc9 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Mon, 1 Jun 2020 21:51:47 -0400 Subject: [PATCH] Bugfix. Audible changed how they handle categories, causing a new bug. Temp fix to get everything working again -- part 2 --- DtoImporterService/UNTESTED/BookImporter.cs | 12 ++++++++++-- DtoImporterService/UNTESTED/CategoryImporter.cs | 2 +- LibationLauncher/LibationLauncher.csproj | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/DtoImporterService/UNTESTED/BookImporter.cs b/DtoImporterService/UNTESTED/BookImporter.cs index edbcc17e..a064cfd3 100644 --- a/DtoImporterService/UNTESTED/BookImporter.cs +++ b/DtoImporterService/UNTESTED/BookImporter.cs @@ -86,8 +86,16 @@ namespace DtoImporterService .ToList(); // categories are laid out for a breadcrumb. category is 1st, subcategory is 2nd - // absence of categories is very rare, but possible - var lastCategory = item.Categories.LastOrDefault()?.CategoryId ?? ""; + // absence of categories is also possible + + // CATEGORY HACK: only use the 1st 2 categories + // (real impl: var lastCategory = item.Categories.LastOrDefault()?.CategoryId ?? "";) + var lastCategory + = item.Categories.Length == 0 ? "" + : item.Categories.Length == 1 ? item.Categories[0].CategoryId + // 2+ + : item.Categories[1].CategoryId; + var category = DbContext.Categories.Local.SingleOrDefault(c => c.AudibleCategoryId == lastCategory); var book = DbContext.Books.Add(new Book( diff --git a/DtoImporterService/UNTESTED/CategoryImporter.cs b/DtoImporterService/UNTESTED/CategoryImporter.cs index d9a747fb..a3789049 100644 --- a/DtoImporterService/UNTESTED/CategoryImporter.cs +++ b/DtoImporterService/UNTESTED/CategoryImporter.cs @@ -51,7 +51,7 @@ namespace DtoImporterService { for (var i = 0; i < pair.Length; i++) { - // not yet supported: depth beyond 0 and 1 + // CATEGORY HACK: not yet supported: depth beyond 0 and 1 if (i > 1) break; diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 5c0cc9d1..21873b09 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 3.1.10.1 + 3.1.11.1