husk.org / blog. chaff. occasional witterings.

2007-08-24

Search Shared iTunes Libraries

computing 15:12:45

A couple of days ago, Chris Heathcote asked "has anyone developed something to search over all networked itunes libraries?" I had a quick think and realised that it was somewhat possible using AppleScript. (Once, I would have recommended a solution using the underlying sharing protocol, DAAP, like my old freshtunes.pl script, but the still-unbroken encryption added in iTunes 7 means that's no longer possible.) It only took about twenty minutes for me to put together a quick and dirty proof of concept yesterday.

However, there's a problem. The iTunes scripting interface only allows searching through already connected iTunes libraries, so you'd have to connect to all of them manually. This is tedious, especially in a campus or company where Macs are widespread. Apple provide the workaround, though: GUI Scripting using Scripting Events. You need to enable "access for assistive devices", and working out the object heirarchies can be very painful (although Prefab's UI Browser makes it a lot easier). So another half an hour or so of poking had a script that will automatically connect to all the libraries, wait half a minute for them to connect, and then search them. So, in case it's useful to anyone, here's the code:

Connect To and Search iTunes Shared Libraries.scpt

Here's the instructions and caveats bit. Copy and paste the above script into a new Script Editor window, save it (to make sure it compiles- watch out for the "not equals" symbol towards the end) and then run it, changing "Orbital" to the name of the band you want to search for. You might find it useful to split it into two scripts, one for connecting to libraries and another for searching.

There are two problems I can think of. Firstly, I don't know how the connection part of the script copes with password-protected shares (or shares that disallow connections because they're too popular), but I suspect it might produce some dialogs that aren't handled well. Secondly, the script uses the visible name for the "Shared" divider in the iTunes source list to choose which libraries to connect to, but this may be different if you're not using iTunes in English, so you might have to edit that part of the script.

Nonetheless, despite the rough edges, I'm fairly sure this will be useful, either as it is for experienced users, or as an starting point for developers. I hope it's useful to you.

2007-10-16

julian

comment 09:47:22

very unorthodox, I know, but could you please email me when you are able. A professional matter. Tks.

2007-10-25

mystic

comment 16:27:06

Any ideas on the following, I haven't had much luck...

-iTunes server W2k3Er2 via Tangerine
-W2k3Er2 has a mapped drive to XP for additional storage

Any iTunes client can see the iTunes server that is on the server's subnet, but no other subnet

How can I manually connect a iTunes client to the server either via network or internet? Other options?

navigation.