spiffin
2/17/2015 - 8:18 PM

AppleScript for displaying the currently playing track, artist and album in LMS (Logitech media Server)

AppleScript for displaying the currently playing track, artist and album in LMS (Logitech media Server)

--Note: only displays notification when run, e.g. via an Alfred keyboard shortcut
--Requires JSON Helper: http://www.mousedown.net/mouseware/JSONHelper.html
--
--Settings
set serverIP to "192.168.1.1" -- your server IP
set portNo to "9000"
set playerID to "xx:xx:xx:xx:xx:xx" -- your player MAC address in Server Settings

--get status feed
set statusFeed to do shell script "curl --data '{\"id\":1,\"method\":\"slim.request\",\"params\":[" & "\"" & playerID & "\"" & ",[\"status\",\"-\",1]]}' http://" & serverIP & ":" & portNo & "/jsonrpc.js"

--parse status feed
tell application "q_json.helper"
	
	set statusJSON to read JSON from statusFeed
	
	set title to title of item 1 of playlist_loop of |result| of statusJSON
	
	set artist to artist of item 1 of playlist_loop of |result| of statusJSON
	
	set album to album of item 1 of playlist_loop of |result| of statusJSON
	
end tell

--Notification output
display notification "from " & album with title title subtitle "by " & artist
--Title and artist only
--display notification "by " & artist with title title