#!/bin/sh #### # # albuminfo.sh [Base directory] # # Tim Nichols: 2006 # tnichols@is-design.com # # Finds all directories containing mp3 or ogg files, and used id3info or # ogginfo get the artist and album names. It then uses amazon.pl to retrieve # album cover art from amazon web services. # # This script is independent of file structure except assuming that each album # is in it's own directory # # amazon.pl is a script written Paul Stuttard, and uses Amazon Web Services to # retrieve album cover art. # It can be found here: # http://www.mail-archive.com/mythtv-users@mythtv.org/msg38848/amazon.pl # # This script depends on id3lib, and ogginfo being installed # id3lib: http://id3lib.sourceforge.net/ # vorbis-tools: http://www.xiph.org/ # #### find ${1:-.} . -type f -name \*.mp3 -o -name \*.ogg -exec dirname {} \; | uniq | while read d do if [ -f "$d"/folder_large.jpg ]; then echo "$d -- already has album art" continue fi # Get a single track from the list of all tracks in the album directory f=$(ls "$d"/*.mp3 "$d"/*.ogg 2>/dev/null| tail -1) # Use id3info if it's an mp3, or ogginfo if it's an ogg case "$f" in *.mp3) info=$(id3info "$f") artist=`echo "$info" | grep TPE1 | sed 's/^[^:]*: *//'` album=`echo "$info" | grep TALB | sed 's/^[^:]*: *//'` ;; *.ogg) info=$(ogginfo "$f") artist=`echo "$info" | grep -i 'artist=' | cut -d= -f2` album=`echo "$info" | grep -i 'album=' | cut -d= -f2` ;; esac # If we found both an artist and an album name, then call amazon.pl # to retrieve the cover art if [ "x$artist" != "x" -a "x$album" != "x" ]; then echo "$d -- Artist: $artist; Album: $album" amazon.pl "$d" "$artist" "$album" else echo "$d -- No Info" fi done