Retrieve Cover Art via MSXML2 call

Hi all,
I’m using MSXML2 with the json format to retrieve information from MusicBrainz.
That woks fine.
Now I would like to retrieve album cover art.
I understood that this has to be fetched via archive.org using the MBID, but I didn’t understand how this exactly works.
Can somebody post any example URL for me?

I tried (for example) this:

The result is an html page and I don’t know how to retrieve the jpg.

Can anybody help?
–Ulrich

The cover art archive has its own API, see Cover Art Archive / API - MusicBrainz

You can get information about the cover art for a release with e.g. https://coverartarchive.org/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd

1 Like

That’s what I was looking for!
Thank you.

Hi outsidecontext,
sorry but I have to ask again.
I get some unexpected error messages.
Calling your URL leads to an redirected URL:
E.g.
https://ia601803.us.archive.org/0/items/mbid-02348ee2-d9c5-44f2-8f5b-3b769e303ea7/index.json
instead of
https://coverartarchive.org/release/02348ee2-d9c5-44f2-8f5b-3b769e303ea7

Entering the redirected path in a firefox browser, I retrieve the JSON Information I want to get.
Retrieving the exact same URL via MSXML2 leads to an “access denied” error - and the MSXML2 Code itself works fine…
Any clue why this might happen or what the reason for the redirection is?
–Ulrich

I don’t know MSXML2. A quick Google search shows it is some XML processing library. Not quite sure why you need this, maybe use some dedicated HTTP request library instead.

But does MSXML2 follow the redirect properly? Can you share the full HTTP response you get? That might contain some details on why your request is failing.

Also set a proper “User-Agent” header with a meaningful user agent. The library by default will most likely set a generic User-Agent instead, maybe that gets blocked.

You could also check with curl if fetching the URL and doing the redirects works in general:

curl -iL "https://coverartarchive.org/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd"

Maybe also one of the existing libraries to access the CAA web service can help: Cover Art Archive / API - MusicBrainz

1 Like

Hi,
ok, I found out how to send a User-Agent string an implemented it.
Unfortunately this was not the reason for my problem, but I’m getting closer.

Please adivce me again, if possible.

I made a wrong assumption.
An Example.
A.) https://coverartarchive.org/release/02348ee2-d9c5-44f2-8f5b-3b769e303ea7
is redirected to
B.) https://ia800303.us.archive.org/8/items/mbid-02348ee2-d9c5-44f2-8f5b-3b769e303ea7/index.json
Using (A) in my code doesn’t work, (B) works fine!
So I replaced the MBID Part of (B) to retrieve a different artwork.

That doesn’t work, because (for example)
C). https://coverartarchive.org/release/2e90656c-f197-35c3-b20a-9e3321f5a271
is redirected to
D.) https://ia600307.us.archive.org/6/items/mbid-2e90656c-f197-35c3-b20a-9e3321f5a271/index.json

The first Part of the URL is allways different when redirected!
So, do you have any idea how to change the URL (A or C) you’ve given me in a way that I can retrieve JSON readable information from it?

– Ulrich

Yes, you can’t use the second URL and replace the IDs. The only proper API request is using https://coverartarchive.org/release/{RELEASE_MBID}

What you describe is indicating that the HTTP library is not following the redirect automatically. You either need to check whether the library supports automatic redirect following (not all do) and set it up accordingly, or you need to implement redirect handling yourself by checking the HTTP status code and Location header of the intial response. Basically the first response returns one of the 3xx redirect status code (302 probably, but you need 5o check) and a Location header with the new URL. Redo a request against this URL.

You might also check whether a different HTTP library works better for you. I haven’t used .Net for years, though, and can’t really give recommendations.

3 Likes

OK,
here we go…
I had to change the Objecttype from “MSXML2.XMLHTTP” to “WinHttp.WinHttpRequest.5.1”.
Then the redirection works.

Thank you for your help!

4 Likes