[Solved] Browse library with websocket API

I don’t manage to browse my library with the API.
I read the documentation, the source code and checked what is sent by the webUI interface to be sure of the command.
Typically I should be able to send and receive these websockets :

["listPlaylist", null] -> ["pushListPlaylist",["Various Artists","YT"]]

["browseLibrary", {uri: "music-library"}] -> ["pushBrowseLibrary",{"navigation":{"prev":{"uri":""},"lists":[{"availableListViews":["list"],"items":[{"type":"folder","title":"USB","service":"mpd","icon":"fa fa-folder-open-o","uri":"music-library/USB"}]}]}}]

But when I send these Python websockets nothing happens:

socketIO.emit("browseLibrary", {"uri":"music-library"})

Please help me, I’m stuck here :confused: My goal is to take a random music from a playlist/folder and add it on queue.
17-02-18 at 20.11.JPG

It only shows the playlists that are listed under “Playlists” (right below Favorites)
If there are none the results of the call will be empty. Add some playlists to the favorites and use the code below to show the results:

You can use code below:

from socketIO_client import SocketIO, LoggingNamespace
import json

def pp_json(json_thing, sort=True, indents=4):
if type(json_thing) is str:
print(json.dumps(json.loads(json_thing), sort_keys=sort, indent=indents))
print(json.dumps(json_thing, sort_keys=sort, indent=indents))
return None

def on_getState_response(*args):
global data
data = args

socketIO.on(‘pushListPlaylist’, on_getState_response)
socketIO.emit(‘listPlaylist’,’’ , on_getState_response)

Thank you defCon it is indeed working to use

socketIO.on('pushListPlaylist', on_getState_response) socketIO.emit('listPlaylist','') socketIO.on('pushBrowseLibrary', on_browse_response) socketIO.emit("browseLibrary", {"uri":"music-library"})
I was excepting to see the response of the server on the console debugger from the VolumioUI but it turns out it’s not broadcasting to all connected clients like other listeners !
I also noticed there is no effect of sending the callback as third parameter, even if it should be the correct practice (pypi.python.org/pypi/socketIO-client#usage).

Thanks again for taking the time to create an account, I’m glad to be able to keep exploring this stuff :slight_smile: