applescript to refresh front row itunes library for media server

Hi All
I set up my mac mini as a home meadia server the other day and am working out the bugs. My MBP and the mini both share a large itunes library located on a firewire disk attached to the mini. I used the option during itunes startup to point both itunes installations to the same library. I’ve got front row running on the mini. An interesting bug popped up in that if I make a change to the library (like adding a song to itunes) from my MBP, the change doesn’t reflect in front row until after I launch itunes on the mini. Both itunes installs are using the same library files and itunes db located on the firewire drive. this is confirmed by the ~/Music folder being empty on both computers.

An interesting note I figured out through testing, in case anyone is interested; iTunes reads the db file once, at startup, and writes changes only upon exiting. Think about what kinda chaos that causes by opening two different itunes installs at the same time, sharing the same library…closing the apps in the wrong order will overwrite changes you made in the other… :slight_smile:

Anyway, the point being, if I update itunes on the mbp, the change won’t show up in front row on the mini until I open itunes on the mini. I started this thinking that frontrow reads the itunes db files when activating, but that’s not the case - apparently, it gets it information directly from the itunes app, running or not, instead of directly from the itunes database itself. Seems like a weak way to do it, (if itunes breaks, so does front row) but whatever - I’m sure there’s a reason. So I wrote a script which runs on the mini to ‘refresh’ the the mini’s itunes so anything I add on the mbp reflects in front row:

try
	do shell script "killall Front\\ Row"
end try
tell application "iTunes"
	activate
	delay 5
	quit
end tell
delay 5
tell application "System Events" to key code 53 using command down

Works like a charm, but It seems there might be a more elegant way of doing this - without exiting and restarting applications. I built delays in to give the apps time to open and close, but what if itunes takes a long time opening or closing?

The ideal way to do it would be to make itunes update itself to the database without opening, but I’m sure that functionality is built directly into the app, so is inaccessible (to me). I was hoping to maybe write the db data into the itunes.app somewhere (perhaps from the unix shell) or make itunes run it’s little ‘read the database’ subroutine independently of running the itunes app, but most of that is over my head.

I also noticed there’s an iTunes Library.xml and an iTunes Library file (presumably a .itbd file) does one of these get written to the other when itunes exits? if so, I could just write a terminal command to write one to the other…

Bottom line, it would be nice to update the database/itunes/front row all in the background, say every 5 or 10 minutes, without inturrupting front row. Currently, I’ll be running this script automatically at like 4am when I’m not using front row - or manually (ick) whenever I add an album or playlist.

Any thoughts?