parseLibraryPodcasts function
- JsonMap response,
- RequestFuncType requestFunc,
- int? limit
Parses podcasts from library.
Implementation
Future<List> parseLibraryPodcasts(
JsonMap response,
RequestFuncType requestFunc,
int? limit,
) async {
final results = getLibraryContents(response, GRID);
if (results == null) return [];
Future<List> parseFunc(List<JsonMap> contents) =>
parseContentList(contents, parsePodcast);
final podcasts = await parseFunc(
(results['items'] as List).sublist(1) as List<JsonMap>,
); // skip first "Add podcast"
if (results.containsKey('continuations')) {
final remainingLimit = limit == null ? null : limit - podcasts.length;
podcasts.addAll(
await getContinuations(
results,
'gridContinuation',
remainingLimit,
requestFunc,
parseFunc,
),
);
}
return podcasts;
}