From f140a1642ebfde198946ad6760c1003c1cb9a8c3 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Sat, 11 Aug 2012 02:40:34 +0200 Subject: scripts --- bin/art.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 bin/art.sh (limited to 'bin/art.sh') diff --git a/bin/art.sh b/bin/art.sh new file mode 100755 index 0000000..4657b4c --- /dev/null +++ b/bin/art.sh @@ -0,0 +1,33 @@ +#!/bin/bash -e +# get_coverart.sh +# +# 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 +# +# 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 "{}" \; +dpath="$1" +encoded="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$dpath")" +# Skip already processed ones +if [ -f "$dpath/cover.jpg" ] +then +echo "$dpath/cover.jpg already exists" +exit +fi +echo "" +echo "Searching for: [$1]" +url="http://www.albumart.org/index.php?srchkey=$encoded&itempage=1&newsearch=1&searchindex=Music" +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" -- cgit v1.2.3-24-g4f1b