Bugfix. Audible changed how they handle categories, causing a new bug. Temp fix to get everything working again -- part 2

This commit is contained in:
Robert McRackan 2020-06-01 21:51:47 -04:00
parent a8b9e187e6
commit c54c45df33
3 changed files with 12 additions and 4 deletions

View File

@ -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(

View File

@ -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;

View File

@ -13,7 +13,7 @@
<!-- <PublishSingleFile>true</PublishSingleFile> -->
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Version>3.1.10.1</Version>
<Version>3.1.11.1</Version>
</PropertyGroup>
<ItemGroup>