a violet pig being the logo of this site

export_amarok_covers – Get the covers out of Amarok

Amarok has the ability to automatically fetch and display cover images for albums contained in its collection. However, these covers are stored in Amarok’s data directory, and not inside the collection directory. This script exports all these covers into the collection directory. Moreover, it can create a Desktop Entry for covers, which is used by compatible file managers (e.g. Dolphin from KDE 4) to display the cover as directory icon.

export_amarok_covers as described on this page is written for Amarok 2. Older versions for Amarok 1.x have been removed from this site, as Amarok 1.x is not supported anymore.

Download

Please fetch the latest version from the downloads page. Refer to the changelog for a list of changes in the release.

Installation

You need Python (at least version 2.6) installed and working. Extract the archive, change into the directory and run:

python setup.py install

This will install the script in /usr/bin/. The prefix can be changed using the --prefix option. The following command will install the script in ${HOME}/bin/:

python setup.py install --prefix ${HOME}

To run the script, the following external modules are required:

  • PIL: Converting between different image formats
  • SQLAlchemy: Easy database access (at least version 0.5)
  • lxml: XML parsing (at least 2.0)

As these packages are very common, they will most likely be available in the package repositories of your distribution. On Gentoo you can use the following command to install them:

emerge dev-python/python-sqlalchemy dev-python/imaging dev-python/lxml

On Debian, Ubuntu and distributions derived thereof use the following command:

aptitude install python-sqlalchemy python-imaging python-lxml

As last resort, all these packages are also available on the PyPI and can therefore be installed with pip:

pip install PIL SQLAlchemy lxml

Usage

Note

As of now, the script does not work with Amarok’s embedded MySQL database, but only, if Amarok is configured to use an external database. Support for internal database is not difficult to implement, but no one wanted it yet.

To get your covers exported, just run:

export_amarok_covers

That’s it. The script then reads the Amarok configuration, connects to the Amarok database and exports all covers, which are not contained in the collection directory. Each album cover will be exported to all directories, which contain files of the corresponding album, so be sure, that your collection is properly sorted!

Additionally you can enable the creation of desktop entries to use the exported covers as directory icons. To do this, use the -e option:

export_amarok_covers -e

Of course, this only works with compatible file managers, but this includes all file managers of modern desktop environments like Gnome or KDE.

In the following there is a detailed description of the mentioned command line options. Some rather unimportant options are not description here, use the --help option to get a complete overview about all supported options.

-n name, --cover-name name

Specifies the name of the exported cover file, under which is can be found in the album directory. The default is cover.png.

If you specify an extension, the cover is converted to the image format denoted by the extension (e.g. .jpg for JPEG format, or .png for PNG format). If you omit the extension, it is guessed from the image format of the cover. In this case, the cover is simply copied to avoid potential quality loss due to repeated compression.

-e, --desktop-entries

Create a Desktop Entry for each exported cover. This desktop entry sets the exported cover as directory icon.

-v, --verbose

By default, the script only outputs error messages, according to the old unix motto: “No news is good news”. With this option, the script is a bit more chatty.

Issues and Feedback

Please report issues, proposals or enhancements to the issue tracker.

If report an issue, please be sure to attach the complete debugging output of the script. Run the script with the following options:

export_amarok_covers --debug --log-sql --logfile export_amarok_covers.log

Now attach the resulting export_amarok_covers.log to the issue.

Development

This script is develop on BitBucket. The complete source code is available in a Mercurial repository:

hg clone https://lunar@bitbucket.org/lunar/amarok_covers

Feel free to fork the repository and send pull requests or patches.

License

This program is free software, you can redistribute and/or modify it under the terms of the WTFPL 2.

Glossary

Desktop Entry
A Desktop Entry is a INI-style configuration file, describing how a program is started, appears in menus, and so on. This format is used by Gnome, KDE and possible others. At least KDE also reads .directory files, which describe the appearance of the containing directory, in particular, which icon it has.

Table Of Contents

Previous topic

Creating an initramfs on gentoo

Next topic

pastemacs – Access Lodgeit from emacs

This Page