Hi Patrick, had a quick look @https://developer.spotify.com/web-api/get-the-users-currently-playing-track/
Explicit is brightly tagged: “explicit”: false,
You’re already grabbing the info, so just need an item to assign the data to and a minor addition to your .py script.
I won’t branch your code, since it is a minor update and my .py code is quite average.
Thanks again for the work on this - you’re a rockstar!
spotify.py
self.oh.sendCommand('spotify_current_track', getJSONValue(resp, ['item','name']))
self.oh.sendCommand('spotify_current_artist', getJSONValue(resp, ['item', 'artists', 0, 'name']))
self.oh.sendCommand('spotify_current_cover', getJSONValue(resp, ['item', 'album', 'images', 1, 'url']))
self.oh.sendCommand('spotify_current_duration', getJSONValue(resp, ['item', 'duration_ms']))
self.oh.sendCommand('spotify_current_progress', getJSONValue(resp, ['progress_ms']))
self.oh.sendCommand('spotify_current_playing', mapValues(getJSONValue(resp, ['is_playing']), { 'True': 'ON', 'False': 'OFF' }))
self.oh.sendCommand('spotify_current_device', getJSONValue(resp, ['device', 'name']))
self.oh.sendCommand('spotify_current_volume', getJSONValue(resp, ['device', 'volume_percent']))
self.oh.sendCommand('spotify_current_context_uri', getJSONValue(resp, ['context', 'uri']))
self.oh.sendCommand('spotify_current_device_id', getJSONValue(resp, ['device', 'id']))
self.oh.sendCommand('spotify_current_playing_explicit', mapValues(getJSONValue(resp, ['item', 'explicit']), {'True': 'ON', 'False': 'OFF' }))
and
*.items
/* Strings to store Player Data */
String spotify_current_track
String spotify_current_artist
String spotify_current_cover
String spotify_current_duration
String spotify_current_progress
Number spotify_current_progress_percent
Switch spotify_current_playing
Switch spotify_current_playing_explicit
TESTED - WORKS - can’t see much else to change.
Since I regularly poll spotify whilst running audio through the house, I’ll be able to filter explicit tracks from my darling children … In addition to the already running Nicky Minaj filter!