mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-01-02 19:08:39 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a80a0cc06 | ||
|
|
aebefac7e6 | ||
|
|
b2d0ee41f2 |
@@ -3,7 +3,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Version>7.10.1.1</Version>
|
||||
<Version>7.10.2.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -131,18 +131,8 @@ namespace AudibleUtilities
|
||||
{
|
||||
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
|
||||
getChildEpisodesTasks.Add(getChildEpisodesAsync(concurrencySemaphore, item));
|
||||
|
||||
items.Add(item);
|
||||
}
|
||||
else if (!item.IsEpisodes)
|
||||
items.Add(item);
|
||||
@@ -174,7 +164,7 @@ namespace AudibleUtilities
|
||||
}
|
||||
|
||||
#region episodes and podcasts
|
||||
|
||||
|
||||
private async Task<List<Item>> getChildEpisodesAsync(SemaphoreSlim concurrencySemaphore, Item parent)
|
||||
{
|
||||
await concurrencySemaphore.WaitAsync();
|
||||
@@ -189,10 +179,9 @@ namespace AudibleUtilities
|
||||
{
|
||||
//The parent is the only episode in the podcase series,
|
||||
//so the parent is its own child.
|
||||
var parentJson = parent.ToJson(parent).ToString();
|
||||
var child = Item.FromJson(parentJson);
|
||||
child.Asin = child.Asin.Replace("SERIES_", "");
|
||||
children.Add(child);
|
||||
parent.Series = new Series[] { new Series { Asin = parent.Asin, Sequence = RelationshipToProduct.Parent, Title = parent.TitleWithSubtitle } };
|
||||
children.Add(parent);
|
||||
return children;
|
||||
}
|
||||
|
||||
foreach (var child in children)
|
||||
@@ -254,8 +243,8 @@ namespace AudibleUtilities
|
||||
{
|
||||
childrenBatch = await Api.GetCatalogProductsAsync(idBatch, CatalogOptions.ResponseGroupOptions.ALL_OPTIONS);
|
||||
#if DEBUG
|
||||
//var childrenBatchDebug = childrenBatch.Select(i => i.ToJson()).Aggregate((a, b) => $"{a}\r\n\r\n{b}");
|
||||
//System.IO.File.WriteAllText($"children of {parent.Asin}.json", childrenBatchDebug);
|
||||
//var childrenBatchDebug = childrenBatch.Select(i => i.ToJson()).Aggregate((a, b) => $"{a}\r\n\r\n{b}");
|
||||
//System.IO.File.WriteAllText($"children of {parent.Asin}.json", childrenBatchDebug);
|
||||
#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -109,7 +109,6 @@ namespace LibationWinForms.GridView
|
||||
=> gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series));
|
||||
public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> gridEntries)
|
||||
=> 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 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;
|
||||
public static bool IsEpisodeChild(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ namespace LibationWinForms.GridView
|
||||
|
||||
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)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user