and I'm all out of bubble gum…

For the past few years (well, since I’ve had an iPad), I’ve been exasperated by the time it takes whichever app Apple has streaming video from my iTunes library to my iPad to load my iTunes library. In the past, it has taken anywhere from 20-90 minutes to load the library each time I access it. Clearly, this isn’t really viable as a “streaming TV in bed” approach. I did some digging around, and it seems like the root issue is that my iTunes library is too big, so the iPad app can’t process the XML file it has to download (aside: this is ridiculous, of course).

Long story short, at the start of the summer, being blissfully unemployed, I took a moment to split my iTunes library in twain: one library of music and audiobooks to sync to my phone (not that that integration has been getting any better, mind you) and one library of movies and TV shows to stream to the AppleTV and my iPad and whatnot. (Note: this whole time the AppleTV could load my gigundous library… but not the iPad. Oy.)

Much metadata cleaning later (because it turns out that iTunes doesn’t actually write all the fields it should write to video files, because, well… it’s lousy), I now have two libraries. Most of the time I want the movies and TV library open, but I want to regularly open the music and audiobooks to sync podcasts (not that I trust Apple for that either: greg is in charge of syncing, iTunes just adds the new files to the library).

In the past, I’ve noted that I’ve found CLI defaults tool to be useful for managing a remote iTunes library. This proves not to be the case here — in fact, the solution is one of simple symlinking. I’ve written three scripts: a “master” script that just toggles between libraries and two “client” scripts that just pass a specific parameter to the master script (depending on which library should be opened).

It’s worth noting a few things here:

  1. I initially tried to do this using system accessibility scripting but found that to be unreliable (pasting the path into the “go to folder” dialog as iTunes opened was flaking reliably).
  2. Along the way, while I could have used the CLI osascript command to open the “master” script with appropriate parameters in the crontab… I couldn’t figure out how to give osascript appropriate permissions in the accessibility section of the Security & Privacy system preferences. Frustrating.
  3. There may be a better way of detecting whether parameters have been passed into the master script than checking if the the on run parameters are a list… or something else (list = a list of parameters, something else = no parameters), but I haven’t seen it. And it works.

July 30th, 2017

Posted In: How To

Tags: , , , ,

I just mentioned that my wife switches between two different iTunes libraries, including one that lives on a shared volume on our home server. There’s a great tip on Stack Overflow for writing a script to automate that swap between iTunes libraries (rather than having to hold down option while iTunes loads and then click around to find the library you want). But it seemed like it might be nice to document for posterity the full script that we’ve built, since it handles not just the library swapping, but also the mounting of the shared volume as well.

This script takes a little prep work, both generating the library location property and storing the authentication information in the user keychain. The Stack Overflow tip explains the former, and the latter is as easy as connecting to the server and remembering to check the “Save Authentication” checkbox during the authentication process.

March 18th, 2014

Posted In: How To

Tags: , ,

A bit of background: my wife has an iTunes library that is too large to fit comfortably on her MacBook Air (in all fairness: I have an iTunes library that is too large to fit on her MacBook Air, my MacBook Pro and several other laptops as well). She maintains a local library on her laptop for use at school (useful movies, songs, etc.) and stores her “real” library on our home server. Which involves a bit of fiddling to get it to work. The key issue is that she needs iTunes to load her library off of a shared disk. And, periodically (maybe every couple of months), something goes haywire and she gets this error:

The iTunes library Library file is locked, on a locked disk, or you do not have write permission for this file.

Needless to say, this is exasperating.

There are a number of suggested solutions out there, and I keep forgetting to bookmark “the one” that works. On my last search, I realized that this was because none of them are really the answer that works in our situation. Here’s what works (and I’m posting this as a note for self):

  1. Disconnect the laptop from the server (quitting iTunes first, of course).
  2. On the server, unset the nouchg flag (not 100% that this is necessary 100% of the time, but it’s necessary at least some of the time):
    sudo chflags -R nouchg
  3. Reboot the server.
  4. Reconnect from the laptop and rejoice.

At least, that’s what worked this evening, and it felt really familiar. (There’s an unspoken step 2a, of course: cancel the multi-hour process on the server that you had queued up moments before iTunes started misbehaving. Argh.)

March 18th, 2014

Posted In: How To

Tags: , , ,