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

Posted by Hodge on Feb 10, 2009 in Linux, Ubuntu5 commentsPrint This Post

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, path.py and SQLAlchemy. Unfortunately, the script creator’s suggested method for installing the dependencies as follows:

sudo easy_install PIL ConfigObj path.py SQLAlchemy argparse

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

wget http://cheeseshop.python.org/packages/source/a/argparse/argparse-0.8.0.zip http://jaist.dl.sourceforge.net/sourceforge/configobj/configobj-4.5.3.zip http://effbot.org/downloads/Imaging-1.1.6.tar.gz http://pypi.python.org/packages/source/p/path.py/path-2.2.zip#md5=941660081788282887f652510d80e64e http://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.5.2.tar.gz#md5=616893cbfb7b04a4f0ca9587bded3a1c
sudo easy_install argparse-0.8.0.zip configobj-4.5.3.zip Imaging-1.1.6.tar.gz path-2.2.zip 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:

MySqlHost=localhost
MySqlPort=3306
MySqlDbName=AMAROK_DB_NAME

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
./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!


Something not quite right? Inaccuracies or invalid code? Didn’t work for you? Don’t like me using Ss instead of Zs? Add a comment below! All comments are welcome. Except spam, because spam is a bit crap.


eBay Logo  

Lot 6 New HP G60 15.6 Laptop Notebook Win 7 HDMI Webcam


Lot 6 New HP G60 15.6 Laptop Notebook Win 7 HDMI Webcam


$3,149.95


Lenovo ThinkPad X201s 5397FFU 5397-FFU Notebook/Laptop


Lenovo ThinkPad X201s 5397FFU 5397-FFU Notebook/Laptop


$2,646.40


Lenovo ThinkPad X201s 5413FFU 5413-FFU Notebook/Laptop


Lenovo ThinkPad X201s 5413FFU 5413-FFU Notebook/Laptop


$2,636.88


New Lenovo ThinkPad W510 43192RU Laptop Notebook


New Lenovo ThinkPad W510 43192RU Laptop Notebook


$2,494.99


Lenovo ThinkPad X200s 7469-5GU 74695GU Notebook/Laptop


Lenovo ThinkPad X200s 7469-5GU 74695GU Notebook/Laptop


$2,385.48


No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Tags: , , , ,

5 comments

» Comments RSS Feed
  1. Thank you so much. I have been wanting to do this for a long time because I have rhythmbox installed on another machine and it only displays artwork that is in the folder. It worked like a charm with one little hiccup. I have 2 folders in my amarok albumcovers folder with artwork in them, large and albumtag. This program only exported the images from the large folder. Most of my album art is stored in the albumtag folder. Any idea what I can do to export these?

  2. worked like a treat except you didn’t explain how to install easy_install but I did figure it out by finding my exact python version egg and installing that by running sudo sh blahblahegg. then I could run the easy_install command. Also, I wonder if there is a script to parse each album folder now and rename the cover.jpg to the name of the folder it’s in? I wish I could write bash scripts!!!!

  3. i meant to say that it would rename the cover.png to the folder’s name.png. oh well.

  4. thanks for the howto i needed this stuff, although other guy has also done a similar work on this synchronising stuff but only for the metadata related to playcount, track rating ,etc have a look at http://developer.gauner.org/bifroest/

    @daniel …. thanks for the howto on easy install

  5. but i have a question the creator has nt used Imaging library where as you have used it … why is that so?

Leave a comment