Make use of unauthenticated API

This commit is contained in:
Michael Bucari-Tovo 2022-06-17 23:09:22 -06:00
parent c4c9786050
commit b710075544
2 changed files with 6 additions and 6 deletions

View File

@ -128,7 +128,7 @@ namespace ApplicationServices
Log.Logger.Information("Begin scan for orphaned episode parents"); Log.Logger.Information("Begin scan for orphaned episode parents");
var newParents = await findAndAddMissingParents(apiExtendedfunc, accounts); var newParents = await findAndAddMissingParents(accounts);
Log.Logger.Information($"Orphan episode scan complete. New parents count {newParents}"); Log.Logger.Information($"Orphan episode scan complete. New parents count {newParents}");
if (newParents >= 0) if (newParents >= 0)
@ -255,7 +255,7 @@ namespace ApplicationServices
} }
} }
static async Task<int> findAndAddMissingParents(Func<Account, Task<ApiExtended>> apiExtendedfunc, Account[] accounts) static async Task<int> findAndAddMissingParents(Account[] accounts)
{ {
using var context = DbContexts.GetContext(); using var context = DbContexts.GetContext();
@ -274,11 +274,11 @@ namespace ApplicationServices
.DistinctBy(s => s.Series.AudibleSeriesId) .DistinctBy(s => s.Series.AudibleSeriesId)
.ToList(); .ToList();
// We're only calling the Catalog endpoint, so it doesn't matter which account we use. // The Catalog endpointdoes not require authentication.
var apiExtended = await apiExtendedfunc(accounts[0]); var api = new ApiUnauthenticated(accounts[0].Locale);
var seriesParents = orphanedSeries.Select(o => o.Series.AudibleSeriesId).ToList(); var seriesParents = orphanedSeries.Select(o => o.Series.AudibleSeriesId).ToList();
var items = await apiExtended.Api.GetCatalogProductsAsync(seriesParents, CatalogOptions.ResponseGroupOptions.ALL_OPTIONS); var items = await api.GetCatalogProductsAsync(seriesParents, CatalogOptions.ResponseGroupOptions.ALL_OPTIONS);
List<ImportItem> newParentsImportItems = new(); List<ImportItem> newParentsImportItems = new();
foreach (var sp in orphanedSeries) foreach (var sp in orphanedSeries)

View File

@ -137,7 +137,7 @@ namespace AudibleUtilities
//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));
} }
else if (!item.IsEpisodes) else if (!item.IsEpisodes && !item.IsSeriesParent)
items.Add(item); items.Add(item);
count++; count++;