You are not logged in.

#1 2010-07-09 21:08:12

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

simple amazon coverart search

fun with the Amazon API!

I've added a simple php page to my domain.  it takes artist/album as url arguments, searches amazon, and (if found) reports back the url of the large cover image.

for example, go here:

http://pbrisbin.com:8080/scripts/albuma … =Nevermind

you'll get back a simple text/plain string:

http://ecx.images-amazon.com/images/I/514q1roTpwL.jpg

pretty bare bones, i know.

here's a simplified usage example in bash (from my coverfetch script):

#!/bin/bash

fetch() {
  local artist="$1" album="$2" file="$3" url cover_url
  
  # simple, just swap space for plus
  #url="http://pbrisbin.com:8080/scripts/albumart.php?artist=${artist// /+}&album=${album// /+}"

  # more robust to define an actual url_encode function to do all the %things
  url="http://pbrisbin.com:8080/scripts/albumart.php?artist=$(url_encode "$artist")&album=$(url_encode "$album")"

  cover_url="$(wget -q -O - "$url")"
  
  if [[ -z "$cover_url" ]] || [[ "$cover_url" = 'no results' ]]; then
    echo "$artist -- $album: cover url not found" >&2
    return
  fi
  
  if wget -q -O "$file" "$cover_url"; then
    echo "$artist -- $album: cover retrieved"
  else
    echo "$artist -- $album: error retrieving cover" >&2
    rm -f "$file"
  fi
}

# do some tag reading / while looping madness and just

fetch 'Some Artist' 'Some Album' '/path/to/album_dir/folder.jpg'

# on each result

it might be a bit slow -- i don't run a production server or anything.

anyway, i did it more as a proof of concept to learn how to interface with amazon using php and SOAP.  figured i'd put it out there since i've seen a few albumart.org scrapers on these here forums and this is a much easier/more reliable approach imo.

if anyone has a use, feel free smile

/edit: woot for 1600 posts

Last edited by brisbin33 (2010-07-09 21:08:50)

Offline

#2 2010-07-10 10:08:30

RaisedFist
Member
From: Romania
Registered: 2007-01-30
Posts: 556
Website

Re: simple amazon coverart search

very nice script

Offline

Board footer

Powered by FluxBB