5

I'd like to be able to do this:

$ pwd
/home/$USER/music/ripped_music/Monty_Python-Instant_Record_Collection
$ ls
01.The_Executive_Intro.mp3
...
16.The_Lumberjack_Song.mp3
$ mystery_command_or_script .
$ ls
01.The_Executive_Intro.mp3
...
16.The_Lumberjack_Song.mp3
album_cover.jpg
$

Somewhere in the guts of Rhythmbox, totem, etc. this is being done. I'd like to be able to do it myself.

I don't need help actually writing a script. I'd really just like to know if there's something like CDDB for album covers. (Scraping albumart.org is the current working solution.)

3
  • 1
    What is it exactly that you want to do with scripts? Do you want to edit scripts that are used by applications and change their values for different/improved functionality or do you want to write new once for a specific application like Rhythmbox?! Can you please edit your question and add more information!
    – v2r
    Mar 29 '12 at 19:41
  • Here's a script to get you started: crunchbanglinux.org/forums/post/114627/#p114627
    – nathwill
    Mar 29 '12 at 22:20
  • Okay, I've edited to show an example of what I'd like to do. Mar 30 '12 at 11:49
7

glyrc is the CLI program you're looking for. Once you've got it compiled and installed, this script will do what you want

#!/bin/ksh

if [[ $# -eq 0 ]]; then
  echo "Usage: $(basename $0) music_file.mp3"
  exit 1
fi

FILE="$1"

ALBUM="$( id3v2 --list "$FILE" |sed -n 's/TALB[^:]*: *//p' )"
ARTIST="$( id3v2 --list "$FILE" |sed -n 's/TPE1[^:]*: *//p' )"

glyrc cover --artist "$ARTIST" --album "$ALBUM"

To compile glyrc following the author's directions you must first

sudo apt-get install libsqlite3-dev libcurl3-dev cmake libglib2.0-dev
0
2

While trying to do the same I found Coverlovin, https://launchpad.net/coverlovin/+download and it worked OK for me.

Thanks to webupd8 for signalling it.

http://www.webupd8.org/2011/02/recursively-download-cover-art-for-all.html

1

gmusicbrowser searches Google Images for cover art.

Rhythmbox, according to its FAQ, uses last.fm to download cover art. It used to use discogs (according to a bug report in 2010 I found) but Rhythmbox got banned from it.

1

This works for now. Unless some "official" way pops up, nathwill's is the answer.

#!/bin/ksh

if [[ $# -eq 0 ]]; then
  echo "Usage: $(basename $0) music_file.mp3"
  exit 1
fi

FILE="$1"

SEARCHTERM="$( \
/usr/bin/id3v2 --list "$FILE" |sed -n '/^Album *: */ {
  s///
  s/ *Year: *\([^,]*\),.*$/ \1/
  s/  */+/g
  p
}' )"

TOP="http://www.albumart.org/index.php?searchkey="
BOT="&itempage=1&newsearch=1&searchindex=Music"
URL="$TOP""$SEARCHTERM""$BOT"

IMGURL="$(wget -O - "$URL" |grep 'View larger image' |head -1 |sed 's/^.*<a href="\([^"]*\)"  *title="View larger image".*$/\1/')"

wget -O cover.jpg "$IMGURL"
1
  • A script that used glyrc to fetch album art and eyeD3 to extract an APIC image inside the mp3 would be an official answer. I'll write one later, but if somebody beats me to the punch, they've answered the question. Apr 29 '12 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.