Saturday, December 14, 2013

Export ratings to mp3 from the iTunes database with Qt and taglib

I recently had some issues with iTunes and lost a few of the entries in the database. Maybe some little bug in iTunes, I don't precisely know. Anyway, this led to some data loss: some of my ratings were lost. I knew it would happen, it was only a matter of time, but this made me think it was time to look for a possible solution: embedding ratings into the mp3 itself.

I wasn't able to find a good tool to do this, even though I'm sure some exist, but I noticed it was pretty simple to implement that myself. So I wrote this little tool you might find useful as well: https://github.com/carlonluca/ITunesEmbed.

The tool will parse the library, extract ratings and play counts and embed those values into the popularimeter frame of the ID3v2 tags of the mp3s in your collection.

How to Build

Building the tool is simple: you just need Qt 4 (Qt 5 should be ok as well, I don't think many changes are needed), taglib and LightLogger. You can install taglib using macports, aptitude or whatever you want.

How to Use

The tool is a command line tool. Run the application without params and the help will be shown. You'll need to export your library to XML using iTunes. Then, provide the absolute file path of the library XML and an email that you want to associate to the data (multiple popularimeter frames can be embedded into the mp3). Beware that all the popularimeter frames associated to the same email address will be removed.

Of course this is just a draft. So look at the code, check what it does and backup your library entirely before starting to do anything. I don't want to be responsible of course if you burn it :-)
Bye!