View Full Version : quick hack: make slimp play what itunes is playing (os x)

Barry Brown
2003-12-10, 16:45
Hi all,

Here's a real hack of an applescript. Using Slimp3 I was thinking: why
am i struggling with the web interface when i have itunes running on my
mac? Since my slimp3 is playing from the same library of music, i
hacked up this code which watches what you're playing in itunes and
plays it on your slimp server.

To get it to work paste it into script editor, then save it as an
application and make sure you click 'stay open'. Or you can download
the app from here:

<http://www.dcs.gla.ac.uk/~barry/Slimp3controller fromItunes.zip>

I say this is a real hack because it relies on your music being
arranged into complete albums - it won't work for playlists. But you
might find it useful. I mute my laptop, use itunes to play the album i
up it comes on my slimp3 (which is attached to my hifi). Why i don't
just run a cable from my hifi to my laptop i don't know.

All the best,


-- DUMB slimp3 controller from itunes
-- Barry Brown 2003 - barry (AT) dcs (DOT) gla.ac.uk
-- Save this script as an application making sure to click keep running
-- When you select an album in itunes the corresponding album (and
hopefully track) will play on the slimp3
-- Not guaranteed to work at all really

global this_name, new_track, this_trackno, server_address

set server_address to "" -- This is the slimp3 server's

set this_name to ""
set this_trackno to 999

to searchReplace(thisText, searchTerm, replacement)
set AppleScript's text item delimiters to searchTerm
set thisText to thisText's text items
set AppleScript's text item delimiters to replacement
set thisText to "" & thisText
set AppleScript's text item delimiters to {""}
return thisText
end searchReplace

on idle
tell application "iTunes"
if (this_name is not the name of the current track) and ((track
number of current track) is not (this_trackno + 1)) then
set new_track to true
set this_name to the name of current track
set next_name to the name of current track
set this_artist to the artist of current track
set this_album to the album of current track
set this_trackno to the track number of current track

if new_track is true then
do shell script ("curl \"http://" & server_address &
(do shell script ("curl \"http://" & server_address &
":9000/status.html?p0=playlist&p1=loadalbum&p2=*&p3=" &
searchReplace(this_artist, " ", "+") of me & "&p4=" &
searchReplace(this_album, " ", "+") of me &
do shell script ("curl \"http://" & server_address &
":9000/status.html?p0=playlist&p1=jump&p2=" & this_trackno - 1
& "\"")
end if
set new_track to false

end if
end tell

end try

return 5
end idle