NAME

MusicRoom::CoverArt - Identify suitable cover images for tracks

DESCRIPTION

This package scans a directory full of images to identify a suitable image for a nominated music track. The software is configured by a specification file that tells it where to find images. Here is an example specification file:

# Look for the ID, then the artist and finally use a default
by_id/<id>.jpg
by_artist/<artist>.jpg
default.jpg

In the function calls the $track argument is assumed to contain a reference to a hash with values for all the attributes that are mentioned in the specification file.

If the package is called like:

use MusicRoom::CoverArt;

my $t1 = {id => "tf6ty2", artist => "Paul Simon", 
           song => "That Was Your Mother",
           album => "Graceland"};

my $jpg1_file = MusicRoom::CoverArt::locate($t1);

The specification file above causes the software to look for the files:

/data/music/meta/art/by_id/tf6ty2.jpg
/data/music/meta/art/by_artist/Paul Simon.jpg
/data/music/meta/art/default.jpg

returning the name of the first one that is found or undefined if there are none of them.

A more reasonable specification file might look like:

by_id/<id>.jpg
by_dirartist/<dir_artist>/<artist> - <name>.jpg
by_dir/<dir_name>.jpg
by_artist/<artist>.jpg
default.jpg

This tells the software to look for:

1. The exact ID
2. A combination of the artist associated with the directory, 
   the real artist and the track name.  This lets us specify 
   an image like "Various Artist/The Byrds - Mr Tambourine Man.jpg"
   which is used whenever that song is found on a Various Artist 
   collection
3. An image that is named the same as the album directory
4. An image of the artist
5. A default image if none of the above are available

my $t1 = {id => "tf6ty2", track => "10", length => "02:51", 
           artist => "Paul Simon", song => "That Was Your Mother",
           album => "Graceland", dir_artist => "Paul Simon",
           dir_album => "Graceland", dir_name => "Paul Simon - Graceland",
           size => "1371741", quality => "7", year => "1986"};
my $t2 = {id => "8nj3vp", track => "06", length => "03:16",
           artist => "The Clash", song => "Tommy Gun", 
           album => "The Singles", dir_artist => "The Clash",
           dir_album => "The Singles", dir_name => "The Clash - The Singles",
           size => "1575705",quality => "7",year => "1978"};