dougscripts.com

unix

May 31 2015 - 10:42 am

Check For Library Corruption With xmllint

A Correspondent recently reported that a script which needed to read the current "iTunes Library.xml" file was failing. This XML file, as you may know, is exported periodically by iTunes and is pretty much an abridged output of the actual iTunes database. Even the XML file exported by iTunes' File > Library > Export Library... command was unable to be read. This suggested that there might be some corruption in the track entries, (I recently had a similar report and that database contained corruption that prevented the XML from being exported; the user reported that the XML had last been updated in 2012.)

iTunes can seem to behave normally even if there are tracks with corrupted track entry data or corrupted metadata in their files. So you might not even be aware of corruption until a third-party appliance elicits errors.

There is a command-line tool called xmllint that can find some corruption in the "iTunes Library.xml". You can run it from Terminal, or in a script like this:

set f to choose file

set rez to (do shell script "xmllint --valid --noout " & quoted form of POSIX path of (f as text))

This will error when it finds some badly encoded or improper UTF-8 text, which is often the culprit. Then it's just a matter of finding the troublesome tracks in iTunes and fixing the problems if possible. Usually this means just editing the tags in iTunes.

July 15 2010 - 10:16 am

NEW: Have a Quick Look v1.0

Inspired by this recent Mac OS X Hint, I've posted Have a Quick Look. This script uses the UNIX qlmanage command to display a Quick Look window of the selected iTunes track(s), which can be audio, video, and, perhaps most usefully, PDF, whereby Preview.app is not necessary. Need I add that a keyboard shortcut makes this very handy.

September 11 2009 - 9:17 am

Need More Sharing From Home Sharing?

If you find the new iTunes 9 feature "Home Sharing" a bit lacking then you may be interested in this remote management compendium I put together a few months ago. If you're ready to really get your hands dirty with things like ssh, rsync, launchd, and more, you can design a system to copy/backup/add any iTunes files to other iTunes apps on your network in the background.

July 13 2009 - 11:35 am

DIY: Remote Management Assortment, Part 5

I've added a Part 5 to DIY: Remote Management Assortment that describes how to create and delete playlists on a remote user's iTunes with ssh and osascript. If you haven't been following along in this series of projects, you may want to start at the beginning; this newest addition builds on routines and concepts from earlier in the series.

June 24 2009 - 4:29 pm

DIY: iTunes Remote Management Assortment

DIY: Remote Management Assortment is a tutorial suggesting several methods of manipulating iTunes files among users on a network, with particular emphasis on using AppleScript to swing passwordless ssh, rsync, scp, osascript, and other utilities. Rather than develop a batch of scripts for you to download (and have to support), you can use the fundamentals described here as the basis for your own AppleScript projects.

January 2 2009 - 7:06 am

Library Follow-Up

After playing around with the "show-library-playlist" setting, it looks like you do have to set "hide-library-playlist" also. So, to show the "Library", run these two commands in Terminal one after the other (that is, press Return after entering each):

defaults write com.apple.iTunes show-library-playlist -bool TRUE
defaults write com.apple.iTunes hide-library-playlist -bool FALSE

To hide the Library again, run the same commands, but reverse the TRUE/FALSE values.

January 1 2009 - 1:59 pm

Show the iTunes Library Old School

I'm not certain if this has been mentioned anywhere--I haven't seen it--but I found the defaults command for displaying the entire iTunes library. Remember when you actually had a large playlist named "Library", before Apple split it up into--what I call--"Master" libraries of "Music", "Movies", "Podcasts", and so on? The "Library" listed everything in your iTunes library. Well, you can get that back using this command in Terminal:

defaults write com.apple.iTunes show-library-playlist -bool TRUE

Quit iTunes before entering the command. When you restart you'll have a new playlist named "Library" at the top of your Source list, above "Music".

If you want to remove the "Library" again, use this command in Terminal:

defaults write com.apple.iTunes show-library-playlist -bool FALSE

There is a second preference called "hide-library-playlist", which I at first thought would have to be set in tandem with the opposite of "show-library-playlist", but this doesn't seem necessary. In fact, you can set one or the other, apparently, and get the desired result; that is setting "show-library-playlist" to TRUE or setting "hide-library-playlist" to FALSE amounts to the same thing. Also, for AppleScript purposes, this playlist can be referenced as library playlist 1; it always could be, but now it is visible.

December 23 2008 - 1:26 pm

Native Half-Star Ratings

This hint at Mac OS X Hints describes a simple terminal defaults command that allows iTunes to accept half-star ratings by drag or inter-star-clicking.

October 1 2008 - 3:29 pm

Banish the Track Numbers from Imported Files

This tip at Mac OS X Hints reveals the defaults command to keep track numbers from being added to the beginning of filenames after importing, a feature that was removed from iTunes' Preferences in iTunes 8. Of course, as one commenter laments, this won't remove the track numbers from files you have already ripped in iTunes 8.

September 9 2008 - 9:15 pm

iTunes 8 Loses Prefs Control for Genre Browser

Switch off the iTunes 8 Genre browser via a defaults write command in Terminal.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.