Batch Export Amarok Album Art to the Album’s Containing Directory

Posted by on Feb 10, 2009 in Linux, Ubuntu8 comments

am21Despite being a Gnome user, I’ve been using Amarok – a KDE application – as my main music player for some time, and love it. I’ve also spent a lot of time within Amarok downloading and importing Album art for almost all of my music, with the exception of a few obscure albums for which Amarok couldn’t find the correct cover from Amazon. The only minor gripe I have so far, is that Amarok stores all the album art it acquires deep in the home directory, with each file named as an MD5 Hash of (I presume) the Artist/Album. No problem, so long as Amarok is the only player I ever use – but what if I want to try, say, Songbird, or import the album art into the ID3 tags of my music collection? It’s not a pleasant task to go through hundreds of albums and manually sort the correct images into the relevant album’s location – in my case, an external drive. Thankfully, help is at hand, with a handy Python script called export_amarok_covers. After setting up some prerequisites, the script can be run once, and it will automatically go through all the albums in Amarok’s database, and copy the correct album art to the respective Album’s location. This is how to get it up and running.

The script itself, can be downloaded here: export_amarok_covers. Simply right click and save it to the Desktop.

System Prerequisites

export_amarok_covers requires Python, python-dev and if your Amarok database is in MySQL, the Python’s MySQL libraries and connectors, as well as python-setuptools which contains scripts such as easy_install. These are easy to set up in Debian/Ubuntu systems. From a Terminal, run:

sudo apt-get install python python-dev python-mysqldb python-setuptools

Python Libraries

export_amarok_covers also requires several Python libraries and dependencies – argparse, ConfigObj, PIL, and SQLAlchemy. Unfortunately, the script creator’s suggested method for installing the dependencies as follows:

sudo easy_install PIL ConfigObj SQLAlchemy argparse

didn’t work for me, so I manually downloaded each library, then installed with easy_install:

sudo easy_install Imaging-1.1.6.tar.gz SQLAlchemy-0.5.2.tar.gz

Final Tweaks

The first time I ran the script, it threw some errors at me, regarding the script’s MySQL connection variables mapping method, which actually turned out to be a problem with my amarokrc file, in which for some reason, some MySQL connection parameters were missing. To remedy this, I edited the file:

gedit ~/.kde/share/config/amarokrc

and added to the [MySQL] section the following lines:


Running export_amarok_covers

Once everything is set up, it’s just a case of making the script executable and running it, so from a Terminal, run:

cd ~/Desktop
chmod +x export_amarok_covers

There are also a number of options, listed on the script creator’s site, which allow you to specify the name of the output file, create Desktop Entries, and so on.

When the script has finished running (it’s very fast), you should find each album art image within the location of the respective album.

Now I need to work on batch importing the covers to the MP3’s ID3 tags!

Tags: , , , ,