Stop using deprecated getPlaylists API.

Get playlist refs from asList().
Get playlist track refs using getItems().
Must then do a library.lookup() for all tracks since we require album metadata when displaying.
This commit is contained in:
Nick Steel 2015-11-12 01:27:55 +00:00
parent bace97cc7c
commit 24cea6d4be
2 changed files with 21 additions and 11 deletions

View File

@ -213,7 +213,7 @@ function toggleSearch() {
function getPlaylists() {
// get playlists without tracks
mopidy.playlists.getPlaylists(false).then(processGetPlaylists, console.error);
mopidy.playlists.asList().then(processGetPlaylists, console.error);
}
function getBrowseDir(rootdir) {
@ -267,8 +267,9 @@ function showTracklist(uri) {
});
// scrollToTracklist();
//lookup recent tracklist
mopidy.playlists.lookup(uri).then(processGetTracklist, console.error);
mopidy.playlists.getItems(uri).then(function(refs) {
processPlaylistItems({'uri':uri, 'items':refs});
}, console.error);
return false;
}

View File

@ -157,6 +157,7 @@ function processBrowseDir(resultArr) {
*********************************************************/
function processGetPlaylists(resultArr) {
if ((!resultArr) || (resultArr == '')) {
$('#playlistslist').empty();
return;
}
var tmp = '', favourites = '', starred = '';
@ -179,15 +180,23 @@ function processGetPlaylists(resultArr) {
}
/********************************************************
* process results of a returned playlist
* process results of a returned list of playlist track refs
*********************************************************/
function processGetTracklist(resultArr) {
//cache result
var newplaylisturi = resultArr.uri;
//console.log(resultArr);
playlists[newplaylisturi] = resultArr;
resultsToTables(playlists[newplaylisturi].tracks, PLAYLIST_TABLE, newplaylisturi);
showLoading(false);
function processPlaylistItems(resultDict) {
var trackUris = []
for (i = 0; i < resultDict.items.length; i++) {
trackUris.push(resultDict.items[i].uri);
}
return mopidy.library.lookup(null, trackUris).then(function(tracks) {
// Transform from dict to list and cache result
var newplaylisturi = resultDict.uri;
playlists[newplaylisturi] = {'uri':newplaylisturi, 'tracks':[]};
for (i = 0; i < trackUris.length; i++) {
playlists[newplaylisturi].tracks.push(tracks[trackUris[i]][0]);
}
resultsToTables(playlists[newplaylisturi].tracks, PLAYLIST_TABLE, newplaylisturi);
showLoading(false);
});
}
/********************************************************