Music library status

In case anyone is curious, here’s a status update on my music library debacle.  I finally got to a point where I had a what should be a clean copy of my music repository on my NFS drive, and I just had to point iTunes at the cleaned repository…

I was resigned by this time to losing all my ratings and play counts, as it seemed that the only method that would work was to delete the existing library and recreate it from a hack of the XML version of the library file.  This was what I started when I got back from holiday.

I backed everything up, then edited the XML file and search-and-replaced the file paths in the entries with the new location.  Then, I deleted the “iTunes Library” file and started iTunes.  Sure enough, empty library.  I selected “Import…” and pointed iTunes at the XML file.  After a fair amount of grinding, it gave me an error saying that “not all the songs could be added as they could not be found”.  Sure enough, only about 1400 of nearly 2600 made it into the library.  My search-and-replace must have been incomplete… 😦

I figured that rather than scratch the library yet again and try and find the 1200-odd entries in the XML file that I had failed to edit correctly, I’d just use “Add to Library…” to bring in the missing files.  This worked correctly, and my iTunes listing was back to its former glory (without play counts and ratings though).

Then the moment of truth — iPod time.  I had not plugged my iPod in at all after the library had blown up, so I was a bit nervous about the possibility of an iPod sync removing all the media and details from the iPod.  I was hoping though that iTunes would read the ratings and play counts off the iPod and restore them to the library.

I sat the iPod in its dock, and got an error about the iPod being synced to a different library.  Nuts.  I reopened the XML file and found a field called “Library Persistent ID” which was different between the original XML file and the new one — so unfortunately iTunes didn’t import the ID from the original file.

At this point I got a little blase about the whole thing.  I’d already trashed the library once, how much worse could it get?  I decided that this ID value had to be in the binary library file somewhere, so went looking for a binary editor that could help.  I found a very cool little program (with an equally cool name) called 0xED that allowed me to edit the iTunes library file — and lo and behold, right there in about the first 100 bytes of the file, was exactly the hex string that was in the XML file.  I shut down iTunes and substituted the old value into the binary library file, and restarted iTunes.  So far so good.  I plugged in the iPod…  and it synced!  The majority of the files were fine, there were a couple of podcast episodes and a few old miscellaneous files that had to be copied to the iPod.  Unfortunately though, the ratings and play counts didn’t come out of the iPod so are presumably gone for good.

So I’m working again, right?  Wrong.  This mess was the kick in the pants I needed to go away from using iTunes for music and switch to something Linux.  The main issue I have is with podcasts — I’ve never really been happy with the Juice/iTunes combination, since Juice splattered podcasts all over my library (it doesn’t put everything neatly into the “Podcasts” directory like iTunes did) — and I forgot the reason I switched from iTunes to Juice for podcatching in the first place.  I’ve got an idea in mind to combine a command-line cron-scheduled podcatcher with the MySQL backend for amaroK, but more on that when (if) I get something working.

Leave a comment