getExplore method
Get latest explore data from YouTube Music.
The Top Songs chart is only returned when authenticated with a premium account.
Returns Map containing new album releases, top songs (if authenticated with a premium account), moods & genres, popular episodes, trending tracks, and new music videos.
Example:
{
"new_releases": [
{
"title": "Hangang",
"type": "Album",
"artists": [
{
"id": "UCpo4SbqmPXpCVA5RFj-Gq5Q",
"name": "Dept"
}
],
"browseId": "MPREb_rGl39ZNEl95",
"audioPlaylistId": "OLAK5uy_mTZAp8a-agh1at-cVUGrwPhTJoM5GnKTk",
"thumbnails": [...],
"isExplicit": false
}
],
"top_songs": {
"playlist": "VLPL4fGSI1pDJn6O1LS0XSdF3RyO0Rq_LDeI",
"items": [
{
"title": "Outside (Better Days)",
"videoId": "oT79YlRtXDg",
"artists": [
{
"name": "MO3",
"id": "UCdFt4Cvhr7Okaxo6hZg5K8g"
},
{
"name": "OG Bobby Billions",
"id": "UCLusb4T2tW3gOpJS1fJ-A9g"
}
],
"thumbnails": [...],
"isExplicit": true,
"album": {
"name": "Outside (Better Days)",
"id": "MPREb_fX4Yv8frUNv"
},
"rank": "1",
"trend": "up"
}
]
},
"moods_and_genres": [
{
"title": "Chill",
"params": "ggMPOg1uXzVuc0dnZlhpV3Ba"
}
],
"top_episodes": [
{
"title": "132. Lean Into Failure: How to Make Mistakes That Work | Think Fast, Talk Smart: Communication...",
"description": "...",
"duration": "25 min",
"videoId": "xAEGaW2my7E",
"browseId": "MPEDxAEGaW2my7E",
"videoType": "MUSIC_VIDEO_TYPE_PODCAST_EPISODE",
"date": "Mar 5, 2024",
"thumbnails": [...],
"podcast": {
"id": "UCGwuxdEeCf0TIA2RbPOj-8g",
"name": "Stanford Graduate School of Business"
}
}
],
"trending": {
"playlist": "VLOLAK5uy_kNWGJvgWVqlt5LsFDL9Sdluly4M8TvGkM",
"items": [
{
"title": "Permission to Dance",
"videoId": "CuklIb9d3fI",
"playlistId": "OLAK5uy_kNWGJvgWVqlt5LsFDL9Sdluly4M8TvGkM",
"artists": [
{
"name": "BTS",
"id": "UC9vrvNSL3xcWGSkV86REBSg"
}
],
"thumbnails": [...],
"isExplicit": false,
"views": "108M"
}
]
},
"new_videos": [
{
"title": "EVERY CHANCE I GET (Official Music Video) (feat. Lil Baby & Lil Durk)",
"videoId": "BTivsHlVcGU",
"artists": [
{
"name": "DJ Khaled",
"id": "UC0Kgvj5t_c9EMWpEDWJuR1Q"
}
],
"playlistId": null,
"thumbnails": [...],
"views": "46M"
}
]
}
Implementation
Future<JsonMap> getExplore() async {
final body = {'browseId': 'FEmusic_explore'};
final response = await sendRequest('browse', body);
final results = nav(response, [...SINGLE_COLUMN_TAB, ...SECTION_LIST]);
final explore = <String, dynamic>{};
for (final result in results as Iterable) {
final browseId =
nav(result, [
...CAROUSEL,
...CAROUSEL_TITLE,
...NAVIGATION_BROWSE_ID,
], nullIfAbsent: true)
as String?;
if (browseId == null) continue;
final contents = nav(result, CAROUSEL_CONTENTS);
switch (browseId) {
case 'FEmusic_new_releases_albums':
explore['new_releases'] = parseContentList(
contents as List<JsonMap>,
parseAlbum,
);
case 'FEmusic_moods_and_genres':
explore['moods_and_genres'] = [
for (final genre in nav(result, CAROUSEL_CONTENTS) as Iterable)
{
'title': nav(genre, CATEGORY_TITLE),
'params': nav(genre, CATEGORY_PARAMS),
},
];
case 'FEmusic_top_non_music_audio_episodes':
explore['top_episodes'] = parseContentList(
contents as List<JsonMap>,
parseChartEpisode,
key: MMRIR,
);
case 'FEmusic_new_releases_videos':
explore['new_videos'] = parseContentList(
contents as List<JsonMap>,
parseVideo,
);
default:
if (browseId.startsWith('VLPL')) {
explore['top_songs'] = {
'playlist': browseId,
'items': parseContentList(
contents as List<JsonMap>,
parseChartSong,
key: MRLIR,
),
};
} else if (browseId.startsWith('VLOLA')) {
explore['trending'] = {
'playlist': browseId,
'items': parseContentList(
contents as List<JsonMap>,
parseSongFlat,
key: MRLIR,
),
};
}
}
}
return explore;
}