Fix my own screwup
This commit is contained in:
parent
9c20250b0a
commit
b2d0ee41f2
@ -131,18 +131,8 @@ namespace AudibleUtilities
|
|||||||
{
|
{
|
||||||
if (item.IsEpisodes && importEpisodes)
|
if (item.IsEpisodes && importEpisodes)
|
||||||
{
|
{
|
||||||
//Helps to distinguish product parrents which have no content
|
|
||||||
//from children which do have content.
|
|
||||||
item.Asin = $"SERIES_{item.Asin}";
|
|
||||||
//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.
|
|
||||||
item.Series = new Series[] { new Series { Asin = item.Asin, Sequence = RelationshipToProduct.Parent, Title = item.TitleWithSubtitle } };
|
|
||||||
|
|
||||||
//Get child episodes asynchronously and await all at the end
|
//Get child episodes asynchronously and await all at the end
|
||||||
getChildEpisodesTasks.Add(getChildEpisodesAsync(concurrencySemaphore, item));
|
getChildEpisodesTasks.Add(getChildEpisodesAsync(concurrencySemaphore, item));
|
||||||
|
|
||||||
items.Add(item);
|
|
||||||
}
|
}
|
||||||
else if (!item.IsEpisodes)
|
else if (!item.IsEpisodes)
|
||||||
items.Add(item);
|
items.Add(item);
|
||||||
@ -189,10 +179,9 @@ namespace AudibleUtilities
|
|||||||
{
|
{
|
||||||
//The parent is the only episode in the podcase series,
|
//The parent is the only episode in the podcase series,
|
||||||
//so the parent is its own child.
|
//so the parent is its own child.
|
||||||
var parentJson = parent.ToJson(parent).ToString();
|
parent.Series = new Series[] { new Series { Asin = parent.Asin, Sequence = RelationshipToProduct.Parent, Title = parent.TitleWithSubtitle } };
|
||||||
var child = Item.FromJson(parentJson);
|
children.Add(parent);
|
||||||
child.Asin = child.Asin.Replace("SERIES_", "");
|
return children;
|
||||||
children.Add(child);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var child in children)
|
foreach (var child in children)
|
||||||
|
|||||||
@ -109,7 +109,6 @@ namespace LibationWinForms.GridView
|
|||||||
=> gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series));
|
=> gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series));
|
||||||
public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> gridEntries)
|
public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> gridEntries)
|
||||||
=> gridEntries.Series().Where(i => i.Children.Count == 0);
|
=> gridEntries.Series().Where(i => i.Children.Count == 0);
|
||||||
public static bool IsEpisodeChild(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any() && lb.Book.SeriesLink.First().Order != AudibleApi.Common.RelationshipToProduct.Parent;
|
public static bool IsEpisodeChild(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode;
|
||||||
public static bool IsEpisodeParent(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any() && lb.Book.SeriesLink.First().Order == AudibleApi.Common.RelationshipToProduct.Parent;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,7 +86,8 @@ namespace LibationWinForms.GridView
|
|||||||
|
|
||||||
var episodes = dbBooks.Where(b => b.IsEpisodeChild()).ToList();
|
var episodes = dbBooks.Where(b => b.IsEpisodeChild()).ToList();
|
||||||
|
|
||||||
foreach (var series in episodes.SelectMany(lb => lb.Book.SeriesLink).DistinctBy(s => s.Series))
|
var allSeries = episodes.SelectMany(lb => lb.Book.SeriesLink.Where(s => !s.Series.AudibleSeriesId.StartsWith("SERIES_"))).DistinctBy(s => s.Series).ToList();
|
||||||
|
foreach (var series in allSeries)
|
||||||
{
|
{
|
||||||
var seriesEntry = new SeriesEntry(series, episodes.Where(lb => lb.Book.SeriesLink.Any(s => s.Series == series.Series)));
|
var seriesEntry = new SeriesEntry(series, episodes.Where(lb => lb.Book.SeriesLink.Any(s => s.Series == series.Series)));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user