diff --git a/Source/AudibleUtilities/ApiExtended.cs b/Source/AudibleUtilities/ApiExtended.cs index 70d338b6..ca09a64b 100644 --- a/Source/AudibleUtilities/ApiExtended.cs +++ b/Source/AudibleUtilities/ApiExtended.cs @@ -133,6 +133,11 @@ namespace AudibleUtilities { //Get child episodes asynchronously and await all at the end getChildEpisodesTasks.Add(getChildEpisodesAsync(concurrencySemaphore, item)); + + //Add the parent to the library because it contains the series + //description, series rating, and series cover art which differ + //from the individual episodes' values. + items.Add(item); } else if (!item.IsEpisodes) items.Add(item); @@ -178,7 +183,7 @@ namespace AudibleUtilities // actual individual episode, not the parent of a series. // for now I'm keeping it inside this method since it fits the work flow, incl. importEpisodes logic if (!children.Any()) - return new List() { parent }; + return new(); foreach (var child in children) { diff --git a/Source/LibationWinForms/GridView/GridEntry.cs b/Source/LibationWinForms/GridView/GridEntry.cs index b20c1287..e6d479f2 100644 --- a/Source/LibationWinForms/GridView/GridEntry.cs +++ b/Source/LibationWinForms/GridView/GridEntry.cs @@ -109,5 +109,6 @@ namespace LibationWinForms.GridView => gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series)); public static IEnumerable EmptySeries(this IEnumerable gridEntries) => gridEntries.Series().Where(i => i.Children.Count == 0); + public static bool IsEpisodeWithSeries(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any(); } } diff --git a/Source/LibationWinForms/GridView/ProductsGrid.cs b/Source/LibationWinForms/GridView/ProductsGrid.cs index 99c52788..f655bf74 100644 --- a/Source/LibationWinForms/GridView/ProductsGrid.cs +++ b/Source/LibationWinForms/GridView/ProductsGrid.cs @@ -84,7 +84,7 @@ namespace LibationWinForms.GridView { var geList = dbBooks.Where(b => b.Book.ContentType is not ContentType.Episode).Select(b => new LibraryBookEntry(b)).Cast().ToList(); - var episodes = dbBooks.Where(b => b.Book.ContentType is ContentType.Episode).ToList(); + var episodes = dbBooks.Where(b => b.IsEpisodeWithSeries()).ToList(); foreach (var series in episodes.Select(lb => lb.Book.SeriesLink.First()).DistinctBy(s => s.Series)) { @@ -117,7 +117,7 @@ namespace LibationWinForms.GridView // add new to top if (existingItem is null) { - if (libraryBook.Book.ContentType is ContentType.Episode) + if (libraryBook.IsEpisodeWithSeries()) { LibraryBookEntry lbe; //Find the series that libraryBook belongs to, if it exists @@ -148,7 +148,7 @@ namespace LibationWinForms.GridView series.NotifyPropertyChanged(); } - else + else if (libraryBook.Book.ContentType is not ContentType.Episode) //Add the new product bindingList.Insert(0, new LibraryBookEntry(libraryBook)); }