I’ve installed the api_explorer extension and am testing the API with the examples given therein.
I’ve created a tracklist. The following
{
"method": "core.tracklist.get_length",
"jsonrpc": "2.0",
"params": {},
"id": 1
}
returns: 3. Also, the following
{
"method": "core.tracklist.get_tl_tracks",
"jsonrpc": "2.0",
"params": {},
"id": 1
}
returns
{"jsonrpc": "2.0", "id": 1, "result": [{"track": {"album": {"date": 2008, "__model__": "Album", "artists": [{"__model__": "Artist", "name": "The Royal Schubert Orchestra", "uri": "spotify:artist:4TzMCWYmKGLdQ7YgJ3n6Ce"}], "uri": "spotify:album:66Exlq5cx3D5PKjt6CGr8B", "name": "Musica Clasica - Franz Schubert"}, "__model__": "Track", "name": "Ave Maria D.389 - Schubert", "uri": "spotify:track:0wYnWuQtmtC4szKYLGyglC", "length": 319000, "track_no": 1, "artists": [{"__model__": "Artist", "name": "The Royal Schubert Orchestra", "uri": "spotify:artist:4TzMCWYmKGLdQ7YgJ3n6Ce"}], "date": 2008, "bitrate": 320}, "__model__": "TlTrack", "tlid": 56}, {"track": {"album": {"date": 2006, "__model__": "Album", "artists": [{"__model__": "Artist", "name": "Hans Zimmer", "uri": "spotify:artist:0YC192cP3KPCRWx8zr8MfZ"}], "uri": "spotify:album:1ibEFICF3urEo7NtEMxgHK", "name": "The Da Vinci Code"}, "__model__": "Track", "name": "Chevaliers De Sangreal", "uri": "spotify:track:4VaOecssBTF02dO0n2u8BS", "length": 247000, "track_no": 13, "artists": [{"__model__": "Artist", "name": "Hans Zimmer", "uri": "spotify:artist:0YC192cP3KPCRWx8zr8MfZ"}], "date": 2006, "bitrate": 320}, "__model__": "TlTrack", "tlid": 57}, {"track": {"album": {"date": 1996, "__model__": "Album", "artists": [{"__model__": "Artist", "name": "Andrea Bocelli", "uri": "spotify:artist:3EA9hVIzKfFiQI0Kikz2wo"}], "uri": "spotify:album:5bwuR4PSrTRlCgRuNS5ZMB", "name": "Romanza"}, "__model__": "Track", "name": "Con Te Partir\u00f2", "uri": "spotify:track:7r3EaAW4FiPCRnPYZ7azfl", "length": 251000, "track_no": 1, "artists": [{"__model__": "Artist", "name": "Andrea Bocelli", "uri": "spotify:artist:3EA9hVIzKfFiQI0Kikz2wo"}, {"__model__": "Artist", "name": "Francesco Sartori", "uri": "spotify:artist:0VtVDsLKIsyiBa1DeAdKbU"}], "date": 1996, "bitrate": 320}, "__model__": "TlTrack", "tlid": 58}]}
My Question: How do I play the tracklist?
I’ve tried:
{
"method": "core.playback.play",
"jsonrpc": "2.0",
"params": {
"tl_track": "spotify:track:0wYnWuQtmtC4szKYLGyglC",
"on_error_step": 1
},
"id": 1
}
which returns an error:
{"jsonrpc": "2.0", "id": 1, "error": {"message": "Application error", "code": 0, "data": {"message": "", "traceback": "Traceback (most recent call last):\n File \"/usr/lib/python2.7/dist-packages/mopidy/utils/jsonrpc.py\", line 130, in _handle_single_request\n result = self._unwrap_result(result)\n File \"/usr/lib/python2.7/dist-packages/mopidy/utils/jsonrpc.py\", line 219, in _unwrap_result\n result = result.get()\n File \"/usr/lib/python2.7/dist-packages/pykka/future.py\", line 299, in get\n exec('raise exc_info[0], exc_info[1], exc_info[2]')\n File \"/usr/lib/python2.7/dist-packages/pykka/actor.py\", line 200, in _actor_loop\n response = self._handle_receive(message)\n File \"/usr/lib/python2.7/dist-packages/pykka/actor.py\", line 294, in _handle_receive\n return callee(*message['args'], **message['kwargs'])\n File \"/usr/lib/python2.7/dist-packages/mopidy/core/playback.py\", line 224, in play\n assert tl_track in self.core.tracklist.tl_tracks\nAssertionError\n", "type": "AssertionError"}}}
and I’ve tried:
{
"method": "core.playback.change_track",
"jsonrpc": "2.0",
"params": {
"tl_track":"spotify:track:0wYnWuQtmtC4szKYLGyglC",
"on_error_step": 1
},
"id": 1
}
which also returns an error:
{"jsonrpc": "2.0", "id": 1, "error": {"message": "Application error", "code": 0, "data": {"message": "'int' object has no attribute 'track'", "traceback": "Traceback (most recent call last):\n File \"/usr/lib/python2.7/dist-packages/mopidy/utils/jsonrpc.py\", line 130, in _handle_single_request\n result = self._unwrap_result(result)\n File \"/usr/lib/python2.7/dist-packages/mopidy/utils/jsonrpc.py\", line 219, in _unwrap_result\n result = result.get()\n File \"/usr/lib/python2.7/dist-packages/pykka/future.py\", line 299, in get\n exec('raise exc_info[0], exc_info[1], exc_info[2]')\n File \"/usr/lib/python2.7/dist-packages/pykka/actor.py\", line 200, in _actor_loop\n response = self._handle_receive(message)\n File \"/usr/lib/python2.7/dist-packages/pykka/actor.py\", line 294, in _handle_receive\n return callee(*message['args'], **message['kwargs'])\n File \"/usr/lib/python2.7/dist-packages/mopidy/core/playback.py\", line 140, in change_track\n self.stop()\n File \"/usr/lib/python2.7/dist-packages/mopidy/core/playback.py\", line 305, in stop\n backend = self._get_backend()\n File \"/usr/lib/python2.7/dist-packages/mopidy/core/playback.py\", line 28, in _get_backend\n uri = self.current_tl_track.track.uri\nAttributeError: 'int' object has no attribute 'track'\n", "type": "AttributeError"}}}
I have also installed the Mopidy-Mopify web extension
pip install Mopidy-Mopify
to test that my server setup was working as expected. This extension is working brilliantly.
What must I execute to get the tracklist to play? Is there a “load” method I’m not calling? I’ve read nearly all of the API documentation to find a solution, but I have obviously missed something.
Thanks for any insights.