protected override async Task <IEnumerable <TrackAudioFeatures> > LoadRemoteResource(Action <int, int> progressCallback, string?market = null) { await trackIdCache.Save(TrackIdsStoreName, new List <string>(TrackIds)); var result = new List <TrackAudioFeatures>(); const int rateLimitDelayMs = 100; const int pageSize = 100; int offset = 0; while (offset < TrackIds.Count()) { var downloaded = (await api.Client.Tracks.GetSeveralAudioFeatures(new(TrackIds.Skip(offset).Take(pageSize).ToList()))).AudioFeatures; progressCallback(offset, TrackIds.Count()); result.AddRange(downloaded); await storageCache.Save(StoreName, downloaded); offset += pageSize; await Task.Delay(rateLimitDelayMs); } return(result); }
protected override async Task <IEnumerable <SavedTrack> > LoadRemoteResource(Action <int, int> progressCallback, string?market = null) { return(await Utility.SynchronizedDownloadPagedResources( (o, p) => api.Client.Library.GetTracks(new() { Offset = o, Limit = p, Market = market }), progressCallback, (tracks) => { _ = storageCache.Save(StoreName, tracks); })); }