Event Handler Script for LadioCast

Added this AppleScript to LadioCast to update from Spotify Radio to Sonos with proper track metadata when on local radio:

set lastName to “”
set lastArtist to “”
set lastAlbum to “”
tell application “Spotify”
set trackName to name of current track
set trackArtist to artist of current track
set trackAlbum to album of current track
end tell
if trackName is not lastName and trackArtist is not lastArtist and trackAlbum is not lastAlbum then
set lastName to trackName
set lastArtist to trackArtist
set lastAlbum to trackAlbum
tell application “LadioCast”
set metadata song to trackName & ” – ” & trackArtist & ” – ” & trackAlbum
end tell
end if
delay 15
end repeat

Seems to work. In LadioCast you can choose this saved script to run as an “event handler” when playing your Icecast stream. One field from Sonos “TuneIn Radio” that I still haven’t been able to propagate is “On Now” but the track metadata shows up correctly under “Information” and Sonos updates each track via Growl.