This post originated from an RSS feed registered with .NET Buzz
by Eric Gunnerson.
Original Post: WMP, album art, and Amazon Web Services
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
So, I'm working on a music playing application (to be revealed sometime around PDC,
or perhaps a bit later if I don't get it working) to play around with Whidbey features.
One of the things I want to do is be able to display the album art.
So, I dust off the docs for WMP - which are a bit spotty in places - and go searching
for the album art. For a media item in WMP, you can fetch various attributes, and
one of them is WM/CoverArt (or something like that). Seems like just the ticket, but
none it's not set for any of the items in my collection.
I go searching for another way to get the art. There's a MoreInfo attribute that you
can fetch for all the items, but it points to a non-existant page. I play around a
bit more and find that I can fix the URL to get to the "More Info" page, which has
a link to the album art. A quick Regex, and I pull the cover art url out. I code it
up, and run it on a small subset of my album selection (about 20 albums). There is
no album art for 5 of the 20 albums.
That's pretty pathetic. It's not like I had a lot of obscure albums there - they were
all albums that had certified at least platinum. Now, it may not have had all the
albums, but it was really slow, so I had that going for me.
A bit of time on Google led me towards Amazon
web services. The SDK is free, and using it is free, as long as you
don't do more than 1 request a second per application (multiple instances can do more).
The Details object has a link to the album art, so I just needed to get that object
for the album. So, I started up VS, added the WSDL as a web reference, and went to
town.
The first attempt was to use keyword searching. That worked well if I as looking for
something like "Green Day Dookie", but something like "rush rush" gives you 282 matches,
some in artist, some in album. The basic problem is that you're just looking at keywords,
and you can't specify album and artist directly. Nor can you find that in the Details
object - it just has a single property named ProductName.
The solution was to do an Artist search. This gives me all albums with a specific
value in the artist field (once again, a keyword search, not an exact search). You
then need to look through all the matches you got back and match against the album
you want. This works, but is a bit ungainly, but at least you don't need to do it
that often.
That gets the first chunk of data, and you have to make other calls 1 second apart
to get the rest. The devtag is given to you when you register with Amazon, and it
identifies who's using the service.