Playing entire playlist with json api


#1

Hi!

Is it possible to play an entire playlist without having to load tracks one by one?
I have used the following commands, but they can not be reproduced. The tracks are not loaded as current playback tracks.

  • {“jsonrpc”: “2.0”, “id”: 1, “method”: “core.tracklist.clear”}
  • {“jsonrpc”: “2.0”, “id”: 1, “method”: “core.playlists.as_list”}
    The answer is: {“jsonrpc”: “2.0”, “id”: 1, “result”: [{“model”: “Ref”, “type”: “playlist”, “name”: “Varios”, " uri “:” m3u:Varios.m3u8 "}]}
  • {“jsonrpc”: “2.0”, “id”: 1, “method”: “core.tracklist.add”, “params”: {“uri”: “m3u:Varios.m3u8”}}
    The answer is: {“jsonrpc”: “2.0”, “id”: 1, “result”: []}
  • {“jsonrpc”: “2.0”, “id”: 1, “method”: “core.playback.play”}

Also, is it possible to activate the random mode of those tracks and that the list is repeatable?
Thanks for the help


#2

Finally i make an script.

requests.post(url, json={‘jsonrpc’: ‘2.0’, ‘id’: ‘1’, ‘method’: ‘core.playback.stop’})
requests.post(url, json={‘jsonrpc’: ‘2.0’, ‘id’: ‘1’, ‘method’: ‘core.tracklist.clear’})
r = requests.post(url, json={‘jsonrpc’: ‘2.0’, ‘id’: ‘1’, ‘method’: ‘core.playlists.lookup’, ‘params’: {‘uri’: ‘m3u:Varios.m3u8’}})
ret = json.loads(json.dumps(r.json()))[‘result’][‘tracks’]
for i in ret:
uri = str(i[‘uri’])
requests.post(url, json={‘jsonrpc’: ‘2.0’, ‘id’: ‘1’, ‘method’: ‘core.tracklist.add’ , ‘params’: {‘uri’: uri}})
requests.post(url, json={‘jsonrpc’: ‘2.0’, ‘id’: ‘1’, ‘method’: ‘core.tracklist.shuffle’})
requests.post(url, json={‘jsonrpc’: ‘2.0’, ‘id’: ‘1’, ‘method’: ‘core.playback.play’})

Regards!