getPlaylistVideos method
Retrieves a list of videos from a playlist given its playlist ID.
Implementation
Future<List<VideoDetailed>> getPlaylistVideos(String playlistId) async {
if (playlistId.startsWith("PL")) {
playlistId = "VL$playlistId";
}
final playlistData =
await constructRequest("browse", body: {"browseId": playlistId});
final songs = traverseList(
playlistData,
["musicPlaylistShelfRenderer", "musicResponsiveListItemRenderer"],
);
dynamic continuation = traverse(playlistData, ["continuation"]);
while (continuation is! List) {
final songsData = await constructRequest(
"browse",
query: {"continuation": continuation},
);
songs
.addAll(traverseList(songsData, ["musicResponsiveListItemRenderer"]));
continuation = traverse(songsData, ["continuation"]);
}
return songs.map(VideoParser.parsePlaylistVideo).toList();
}