Hi. Since I've been having trouble with Canola displaying cover art, I ended up modifying a script I had to copy album art from Amarok to the structure Canola uses. I'm not really a coder, but it works for me, so maybe somebody finds this useful as well. Remember to set an output path and if you're using mysql, comment 'database=sqlite' and uncomment 'database=mysql'. After it's done, just copy the contents of the output path into /home/user/.canola/covers.
Cheers.
Code:
#!/bin/bash
#################################
# Configuration #
#################################
# Output directory, no trailing slash
coversdir="/set/path/here"
# Uncomment one of the following
#database=mysql
database=sqlite
# Directory where amaroK's album art is
cd ~/.kde/share/apps/amarok/albumcovers/large
#################################
# End Configuration #
#################################
# Check if Amarok is running
dcop amarok >/dev/null 2>&1
if [[ $? = 1 ]]; then echo "Amarok must be running"; exit 1; fi
# Check if covers directory exists
if [[ ! -d "$coversdir" ]]; then echo "$coversdir does not exist"; exit 1; fi
# Check if imagemagick is installed and in your path
convert >/dev/null 2>&1
if [[ $? = 127 ]]; then echo "This script requires imagemagick"; exit 1; fi
# Check if md5sum is installed and in your path
md5sum --version >/dev/null 2>&1
if [[ $? = 127 ]]; then echo "This script requires md5sum"; exit 1; fi
# function to actually copy the files
copyalbumart() {
# check for forbidden characters
cleanartist=$(echo "$artist" | sed "s/\// /g")
cleanalbum=$(echo "$album" | sed "s/\// /g")
#if [[ -d "$coversdir"/"$cleanartist"/"$cleanalbum" ]]; then
mkdir -p "$coversdir"/"$cleanartist"/"$cleanalbum"
convert "$inputfile" -resize 256x256 "$coversdir"/"$cleanartist"/"$cleanalbum"/cover.jpg
convert "$inputfile" -resize 128x128 "$coversdir"/"$cleanartist"/"$cleanalbum"/cover-small.jpg
echo "Succesfully copied $artist - $album"
#fi
}
copycovers() {
while IFS=^ read artist album; do
# concatenate, lowercase, md5sum
inputfile=$(echo -n $artist$album | tr '[:upper:]' '[:lower:]' | md5sum -)
# strip trailing characters
inputfile=${inputfile%???}
if [[ -f "$inputfile" ]]; then # if the file exists
copyalbumart
else
# If it doesn't exist in amarok's folder, let's see if we
# can find one elsewhere. This'll only match one if it
# contains the word 'cover' or 'front'. If you've got any
# more matching ideas, please tell me
case "$database" in
"mysql") inputfile=$(dcop amarok collection query "SELECT CONCAT(devices.lastmountpoint, '/', images.path) FROM images, devices WHERE devices.id = images.deviceid AND images.artist='$artist' AND images.album='$album' AND (images.path like '%front%' OR images.path like '%cover%') LIMIT 1");;
"sqlite") inputfile=$(dcop amarok collection query "SELECT devices.lastmountpoint || '/' || images.path FROM images, devices WHERE devices.id = images.deviceid AND images.artist='$artist' AND images.album='$album' AND (images.path like '%front%' OR images.path like '%cover%') LIMIT 1");;
esac
if [[ -f "$inputfile" ]]; then
copyalbumart
else
echo "Can't find a cover for "$artist" - "$album""
fi
fi
done
}
# Get Artist^Album pair (using ^ as IFS, if you have an artist or
# album with this character this'll probably fail)
case "$database" in
"mysql") dcop amarok collection query "SELECT DISTINCT CONCAT(artist.name,'^',album.name) FROM album, artist, tags WHERE album.id = tags.album AND artist.id = tags.artist" | copycovers;;
"sqlite") dcop amarok collection query "SELECT DISTINCT artist.name || '^' || album.name FROM album, artist, tags WHERE album.id = tags.album AND artist.id = tags.artist" | copycovers;;
*) echo "Set your database under Configuration";;
esac
Cheers.