Get Album Art is CLI (comment line interface) PHP script designed to locate and download the CD cover art for any given album. Currently it will search buy.com, walmart.com, and amazon.com (in that order) and download the first image it finds matching the appropriate criteria (title match, image dimensions, etc.). In the event that it finds multiple matches on a single site, it will download all appropriate images and the user can manually choose which one to keep. Get Album Art can also optionally create a freedesktop.org directory icon, which can be read by compatible file managers to display the album cover instead of a generic folder icon when viewing that album directory (ImageMagick is required for this option).
Get Album Art is written in PHP 4. It was originally written for Linux, but should be easily portable to any other platform that supports PHP.
getalbumart.php tarball (3.33 KB) - This is a compressed version of the Get Album Art PHP script.
ChangeLog - Get Album Art development details
Installation of Get Album Art is simple:
tar zxf getalbumart.tgz
chmod a+x /usr/local/bin/getalbumart.php)
To complete installation, please open up getalbumart.php in any text editor and verify that the programs defined in the "Setup environment" section are installed, and modify the path to each as appropriate.
getalbumart.php -h to display the Get Album Art help information. This will describe the syntax for running the program and list all available options.
To download an album cover, the album title and artist's name must be specified. This can either be done by specifying both on the command line with the
-r parameters, or by passing
-c to let Get Album Art determine it automatically from the directory names. In order for the
-c parameter to work, the album must be stored in this directory structure:
/path/to/music/Artist Name/Album Name/
If you do not follow this naming convention, you must specify the
-r parameters. Additionally, the
-p parameters can be used to specify how and where the images are saved, and
-d will instruct Get Album Art to create a freedesktop.org directory icon.
When getalbumart.php is executed, it begins by verifying that all arguments are correctly passed, and verifies that ImageMagick is available if
-d is specified. It then checks to see if an image already exists for this album; if found, Get Album Art will not download a new image.
If no existing image is found, Get Album Art builds the search strings for buy.com, walmart.com, and amazon.com, then search each store in order. If the search only returns a single result, the cover image for that album will be downloaded and verified. If multiple results are returned, Get Album Art determines the album cover URL for each result and downloads all available covers for verification. Image verification ensures that any downloaded image meets minimum dimension requirements (to ensure we get a good quality image rather than a thumbnail) and, in the case of multiple matches, that only unique images are saved.
Any images that meet the requirements are named appropriately and saved; all remaining images are deleted. If at least one image is saved, Get Album Art will create the freedesktop.org directory icon (if specified), then exit. If no images are found at the given store, Get Album Art begins processing the next store, and repeats the process.