42 Astoundingly Useful Scripts and Automations for the Macintosh

Catalina: iTunes Library XML

What does Catalina mean for 42 Astounding Scripts?

Jerry Stratton, October 19, 2019

Why is XML so difficult in Python?: Why is XML so difficult… automatically extends to “in Python”.; Python; XML; Google

Apparently I’m not the only one to wonder why XML parsing is so much more difficult in Python than in other scripting languages.

I apologize in advance, but I usually wait at least one iteration before upgrading my operating system. That means at least 10.15.1 and perhaps 10.15.2. I rely too much on my computer to be one of the post-release beta-testers.

The big change in Catalina so far, as far as 42 Astounding Scripts is concerned, is that the iTunes replacement in Catalina does not have a “Share iTunes Library XML with other applications” option. This is causing a lot of problems for DJs, who use iTunes/Music to manage their collections but use other applications for gigs. And if you use the itunesLists script from 42 Astounding Scripts you’ll find that your own iTunes Music Library.xml file will no longer update either.

You can get around this problem by manually exporting an XML file from the Music app.

  1. Open the Music app.
  2. Under the File menu, choose Library and then Export Library.
  3. Name the file “iTunes Music Library.xml” and store it in the iTunes folder in your Music folder. You should know where it goes because there will already be one there.
  4. Save the file.

You’ll need to do this every time your library changes and you care about those changes; Music will not automatically update the XML file like iTunes did.

As I wrote in the book, these are all scripts I use regularly. So I’ll be looking at updating the script to remove its reliance on an XML data file. This will likely involve rewriting the script in swift; some of its more esoteric functionality will probably disappear. The main thing I use the script for is copying music playlists from the Mac to an SDHC card, and that’s what the new script will likely focus on.

I have to confess that removing XML support from the Music app was a completely unexpected change to me. XML is an extraordinarily useful data format, very well suited for exchanging hierarchical data—such as artists->albums->tracks—between applications. I partially blame Python’s developers. Python’s XML library has always been difficult to use. That’s why the itunesLists script requires installing the lxml library. Without that library, XML is much more convoluted in Python.

MacOS uses, or used, Python heavily for its own built-in management utilities; had Python’s built-in XML been easier to use, I suspect that those built-in utilities would use XML more heavily than they do. And that would mean that macOS applications would use XML more than they do.

  1. <- 42 Astounding Scripts is live!
  2. Catalina Scripts ->