Echo Speaks - parsing alexaPlaylists into JSON

The Echo Speaks DTH developed by @tonesto7 defines the attribute “alexaPlaylists” as a “JSON_OBJECT”. The online Echo Speaks documentation for alexaPlaylists shows the following example (which is a valid JSON):

However, my Echo Speaks device has the alexaPlaylists string value as:

[alexaPlaylists]:
‘{Boston=[{entryList=null, playlistId=2434569a-85a0-4493-80cc-74c751d45557, title=Boston, trackCount=8, version=2}], My Griffin House=[{entryList=null, playlistId=2c04552a-68ee-4f9b-9bb4-a4b48262124f, title=My Griffin House, trackCount=69, version=3}]}’

Does anyone have some thoughts on how to convert this unquoted and non standard object string into a JSON format?

I have tried to find what data string format this is as well as tried groovy’s json.slurper parsetext options and python’s json.loads without any luck.

Thanks!

Here is what I developed for Python. It seems primitive to have to do this routine when the value by Echo Speaks documentation is a JSON object. I did create an Echo Speaks GitHub bug report to hopefully have this value reflect a valid JSON string in a future release.

import re
alexaPlaylists = '{Boston=[{entryList=null, playlistId=2434569a-85a0-4493-80cc-74c751d45557, title=Boston, trackCount=8, version=2}], My Griffin House=[{entryList=null, playlistId=2c04552a-68ee-4f9b-9bb4-a4b48262124f, title=My Griffin House, trackCount=69, version=3}]}'
for alexaPlaylist in alexaPlaylists[1:-3].split('}], '):
    alexaPlaylistObj = re.search("^(.*?)=.*?playlistId=(.*?),.*",alexaPlaylist)
    print "Playlist Name: {}, Id={}".format(alexaPlaylistObj.group(1),alexaPlaylistObj.group(2))

If it is used to resume what was previously playing, then it is probably in the forum that it needs to be for the app.

1 Like

Thanks.

The current Echo Speaks DTH does not support the ‘mediaPresets’ capability like the Sonos DTH does, so I added a feature request in the Echo Speak GitHub Issues to hopefully get this in a future release!

Right now, at least ST BitBar users will be able to see the Echo Speaks devices favorite list so they can orally invoke them. With Sonos, they can click on a playlist favorite and Sonos will start playing that playlist. It would be great if all media playback devices had the mediaPresets capability if their API allows.

1 Like