Log in

No account? Create an account
LogJam [entries|archive|friends|userinfo]

[ website | LogJam ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

iTunes music detection script? [Jan. 10th, 2006|07:11 pm]
[Current Mood |curiouscurious]

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?

From: evan
2006-01-11 12:15 am (UTC)
Which platform?

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.
(Reply) (Thread)
[User Picture]From: broonie
2006-01-11 12:19 am (UTC)
Might be worth looking at what iScrobbler does to do this...
(Reply) (Parent) (Thread)
From: ex_trurl
2006-01-11 12:20 am (UTC)
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";
(Reply) (Parent) (Thread)
From: evan
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.
(Reply) (Parent) (Thread)
From: ex_trurl
2006-01-11 03:29 am (UTC)
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.
(Reply) (Parent) (Thread)
[User Picture]From: shadowpillar
2006-01-11 02:50 am (UTC)
Any tips for banshee? if I find any out, I'll let you know, btw
(Reply) (Thread)
From: ex_trurl
2006-01-11 03:28 am (UTC)
What's banshee?
(Reply) (Parent) (Thread)
[User Picture]From: shadowpillar
2006-01-11 07:36 am (UTC)
an itunes-like program under linux

think rhythmbox, but not as slow and bloated. and uses mono
(Reply) (Parent) (Thread)
[User Picture]From: theemptied
2006-01-11 07:49 am (UTC)
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.
(Reply) (Thread)
From: ex_trurl
2006-01-11 01:59 pm (UTC)
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.
(Reply) (Parent) (Thread)