How do I pull album art thumbnail from Bandcamp?

Viewed 150

I'm developing a program that takes a YouTube or Bandcamp link to a song and automatically pulls the associated album artwork or thumbnail.

For YouTube, it's a simple process. There is a server that returns the image. An example of a request would be the YouTube track id inserted into the link, like so:

https://img.youtube.com/vi/${id}/mqdefault.jpg

I am trying to find a similar method to pull album art from Bandcamp but I've had no luck. Further, the API they offer only let's you interact with your own account.

1 Answers

First you need to get the track ID. To do that, you can make a request like this:

http://bandcamp.com/api/url/2/info?key=SECRET&url=duststoredigital.com/track/sudden-intake

However you need a key to use this method. I found a few keys online, but that will be up to you if you want to try to find your own. I emailed them, but it seems they aren't giving out keys any more:

Date: Fri, 17 Sep 2021 21:31:29 +0000
From: Bandcamp Support <support@bandcamp.com>
Subject: Re: (Case 1268890) API Access

Thanks for your interest. Our APIs are currently limited to Label Accounts
(bandcamp.com/labels) looking to pull physical order and general sales
information, though that might change down the road. Please keep an eye on
bandcamp.com/developer for updates.

As a workaround, you can make a request like this:

HEAD /track/amaris-2 HTTP/1.1
Host: schnaussandmunk.bandcamp.com

and in the response should be this:

Set-Cookie: session=1 r:["nilZ0t2809477874x1633448962"] t:1633448962; domain=.bandcamp.com

In this case, t is the tralbum_type and 2809477874 is the tralbum_id. Once you have the track ID, you can make a request like this:

http://bandcamp.com/api/mobile/24/tralbum_details?band_id=1&tralbum_type=t&tralbum_id=2809477874

In the response should be something like this:

"art_id": 3809045440,

Then you can format a URL like this:

http://f4.bcbits.com/img/a<ARTID>_<FORMAT>.jpg

Formats here:

height: format,
100:  3,
124:  8,
135:  15,
138:  12,
150:  7,
172:  11,
210:  9,
300:  4,
350:  2,
368:  14,
380:  13,
700:  5,
1200: 10,
1500: 1,

I have a package for all this, but it's in another language:

https://github.com/89z/mech

Related