我正在开发一个程序,该程序将YouTube或Bandcamp链接到一首歌曲,并自动提取相关的专辑插图或缩略图。
对于YouTube来说,这是一个简单的过程。有一个返回图像的服务器。请求的一个例子是插入链接中的YouTube曲目id,如下所示:
https://img.youtube.com/vi/${id}/mqdefault.jpg
我正试图找到一种类似的方法来从Bandcamp中提取专辑艺术,但我运气不佳。此外,他们提供的API只允许您与自己的帐户进行交互。
首先,您需要获得曲目ID。要做到这一点,您可以提出这样的请求:
http://bandcamp.com/api/url/2/info?key=SECRET&url=duststoredigital.com/track/sudden-intake
但是,使用此方法需要一个密钥。我在网上找到了一些钥匙,但如果你想找到自己的钥匙,那就由你自己决定了。我给他们发了电子邮件,但他们似乎不再发放钥匙了:
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.
作为一种变通方法,您可以提出这样的请求:
HEAD /track/amaris-2 HTTP/1.1
Host: schnaussandmunk.bandcamp.com
在回应中应该是这样的:
Set-Cookie: session=1 r:["nilZ0t2809477874x1633448962"] t:1633448962; domain=.bandcamp.com
在这种情况下,t
是tralbum_type
,而2809477874
是tralbum_id
。一旦你有了曲目ID,你就可以提出这样的请求:
http://bandcamp.com/api/mobile/24/tralbum_details?band_id=1&tralbum_type=t&tralbum_id=2809477874
在回应中应该是这样的:
"art_id": 3809045440,
然后你可以像这样格式化一个URL:
http://f4.bcbits.com/img/a<ARTID>_<FORMAT>.jpg
此处的格式:
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,
我有一个包,但它是另一种语言:
https://github.com/89z/mech