multiScrobble method
Scrobbles a list of Scrobbles, in blocks of maxScrobblesPerRequest.
A list longer than 50 is split into sequential requests, and the result is a single ScrobbleResponse whose counters are the sums. See TrackMethods.scrobble and Scrobble for more information.
Implementation
Future<ScrobbleResponse> multiScrobble({
required List<Scrobble> scrobbleList,
}) async {
if (!_api.isAuth) {
return Future.error(
ScrobblenautException(
description: "You can't use this method unless you Authenticate.",
),
);
}
if (scrobbleList.isEmpty) {
return Future.error(
ScrobblenautException(
description: "You've supplied an empty list of scrobbles.",
),
);
}
final responses = <ScrobbleResponse>[];
for (
var start = 0;
start < scrobbleList.length;
start += maxScrobblesPerRequest
) {
final remaining = scrobbleList.length - start;
final end = start +
(remaining < maxScrobblesPerRequest
? remaining
: maxScrobblesPerRequest);
responses.add(await _scrobbleChunk(scrobbleList.sublist(start, end)));
}
return ScrobbleResponse.merge(responses);
}