How To Download Album Cover Art

From Ludicrous-Speed
Jump to: navigation, search

Get Music Album Cover Art

The following simple shell script will try to search for a matching cover art image file. It then downloads that image and places it into the provided album path. ./Tonic/Lemon Parade ./Metallica/Load

Or, you can recursivly fetch album art for all directories with the following

find . -type d -exec ./get_coverart {} \;

Here is the script contents

#!/bin/bash -e
# This simple script will fetch the cover art for the album information provided on the command line.
# It will then download that cover image, and place it into the child directory.
# The term "album information" is really the relative path of the final directory.
# get_coverart <relative-path>
# get_coverart Tonic/Lemon Parade
# get_coverart Tonic/Lemon\ Parade
# get_coverart Tonic/Lemon_Parade
# To auto-populate all directories in the current directory, run the following command
# find . -type d -exec ./get_coverart "{}" \;
encoded="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$dpath")"
# Skip already processed ones 
if [ -f "$dpath/cover.jpg" ]
echo "$dpath/cover.jpg already exists"
echo ""
echo "Searching for: [$1]"
echo "Searching ... [$url]"
coverurl=`wget -qO - $url | xmllint --html --xpath  'string(//a[@title="View larger image" and starts-with(@href, "http://ecx.images-amazon")]/@href)' - 2>/dev/null`
echo "Cover URL: [$coverurl]"
wget "$coverurl" -O "$dpath/cover.jpg"