getMoodPlaylists method
- String params
Retrieve a list of playlists for a given "Moods & Genres" category.
paramsparams obtained by getMoodCategories.
Returns List of playlists in the format of getLibraryPlaylists. // TODO getLibraryPlaylists is currently missing
Implementation
Future<List> getMoodPlaylists(String params) async {
final playlists = <dynamic>[];
final response = await sendRequest('browse', {
'browseId': 'FEmusic_moods_and_genres_category',
'params': params,
});
for (final section in List<JsonMap>.from(
nav(response, [...SINGLE_COLUMN_TAB, ...SECTION_LIST]) as List,
)) {
List path = [];
if (section.containsKey('gridRenderer')) {
path = GRID_ITEMS;
} else if (section.containsKey('musicCarouselShelfRenderer')) {
path = CAROUSEL_CONTENTS;
} else if (section.containsKey('musicImmersiveCarouselShelfRenderer')) {
path = ['musicImmersiveCarouselShelfRenderer', 'contents'];
}
if (path.isNotEmpty) {
final results = nav(section, path);
playlists.addAll(
await parseContentList(
List<JsonMap>.from(results as List),
parsePlaylist,
),
);
}
}
return playlists;
}