|iTunes music detection script?
||[Jan. 10th, 2006|07:11 pm]
Has anyone ever written a script to allow iTunes music detection from LogJam? I could swear I've heard of such a thing but haven't been able to find one.
If not, how difficult is the protocol? Looking at the XMMS client, it seems it just takes in a "session number" and spits out a string to standard out. However, I'm assuming that the session number is only relevant to XMMS?
2006-01-11 12:15 am (UTC)
The session number is specific to XMMS.
All you really need is a program that outputs the current music in iTunes... maybe you could figure out an AppleScript command that does this.
Might be worth looking at what iScrobbler
does to do this...
I'm running LogJam on MacOS X (and Linux).
Indeed, AppleScript works nicely. While waiting for an answer I actually manged to write up the following which appears to work. I don't know if there is something nearly as simple that can be done for iTunes on Windows.
state=`osascript -e 'tell application "iTunes" to player state as string'`;
if [ $state = "playing" ]; then
ARTIST=`osascript -e 'tell application "iTunes" to artist of current track as string'`;
ALBUM=`osascript -e 'tell application "iTunes" to album of current track as string'`;
TRACK=`osascript -e 'tell application "iTunes" to name of current track as string'`;
echo "$ARTIST - $ALBUM ($TRACK)";
echo "Nothing currently playing";
2006-01-11 02:21 am (UTC)
Sweet! Does it work from within LogJam, then?
I wonder what the most portable way to detect the platform is... probably should do it in the configure script.
Yup. I just made a few posts using the script earlier and it seems to work just fine. Obviously there are number of things one might imagine doing to making formatting more configurable and so forth, but the basics are there.
Any tips for banshee? if I find any out, I'll let you know, btw
an itunes-like program under linux
think rhythmbox, but not as slow and bloated. and uses mono
In XMMS, I use the SongChange plugin which allows me to define things to do when the song changes. I have this in there:
echo "%s" > ~/.now_playing
Then, in Logjam Custom Command,
ssh loot 'cat .now_playing'
That, combined with my ssh keys (for my fileserver, where I play tunes) means my laptop knows what my desktop is playing.
Probably not helpful to you, but it goes to show that maybe you can use some shell or perl or whatever glue to make it work.
Interesting. I hadn't thought about having it check remotely, but that would be very useful too, for exactly when I'm writing on my laptop instead of my desktop.