从 musicbrainz 获取专辑、专辑封面和 运行 时间信息
Getting album, album art, and run time info from musicbrainz
有没有办法获取艺术家(乐队)的专辑列表,以及 link 专辑封面和运行时间?
我得到了这个端点,但它 returns 的数据令人困惑:
http://musicbrainz.org/ws/2/recording?query=artist:%22Queen%22%20and%20type:album&fmt=json
数据并不是真正围绕专辑组织的,"length" 数据 returns 大约是 203000。但是如果你在上下文中看到它会更好,所以这是它的第一部分(抱歉,我无法缩进):
{
"created": "2018-02-17T03:47:57.052Z",
"count": 9533710,
"offset": 0,
"recordings": [
{
"id": "c2e919f7-ecb9-4fdf-9162-3c26d0127fa0",
"score": "100",
"title": "Son and Daughter",
"length": 203000,
"video": null,
"artist-credit": [
{
"artist": {
"id": "0383dadf-2a4e-4d10-a46a-e9e041da8eb3",
"name": "Queen",
"sort-name": "Queen",
"disambiguation": "UK rock group",
"aliases": [
{
"sort-name": "Queen + Adam Lambert",
"name": "Queen + Adam Lambert",
"locale": null,
"type": null,
"primary": null,
"begin-date": "2011",
"end-date": null
}
]
}
}
],
"releases": [
{
"id": "bb19abaf-80b3-4a3e-846d-5f12b12af827",
"title": "Queen",
"status": "Official",
"release-group": {
"id": "810068af-2b3c-3e9c-b2ab-68a3f3e3787d",
"primary-type": "Album"
},
"date": "1994",
"country": "NL",
"release-events": [
{
"date": "1994",
"area": {
"id": "ef1b7cc0-cd26-36f4-8ea0-04d9623786c7",
"name": "Netherlands",
"sort-name": "Netherlands",
"iso-3166-1-codes": [
"NL"
]
}
}
],
"track-count": 10,
"media": [
{
"position": 1,
"format": "CD",
"track": [
{
"id": "3a26455e-2660-30dc-a652-6a2b40f1fbe5",
"number": "8",
"title": "Son and Daughter",
"length": 203400
}
],
"track-count": 10,
"track-offset": 7
}
]
},
{
"id": "1783da6a-9315-3602-a488-1738eb733a0f",
"title": "Queen",
"status": "Official",
"release-group": {
"id": "810068af-2b3c-3e9c-b2ab-68a3f3e3787d",
"primary-type": "Album"
},
"date": "1973-09-04",
"country": "US",
"release-events": [
{
"date": "1973-09-04",
"area": {
"id": "489ce91b-6658-3307-9877-795b68554c98",
"name": "United States",
"sort-name": "United States",
"iso-3166-1-codes": [
"US"
]
}
}
],
如果有人能向我解释这些数据,那么我就不需要另一个端点了。但我一直在寻找 musicbrainz 文档,但它们并不是很有帮助。
最好是一次调用,但如果需要我可以连续调用。
感谢您的帮助。
您需要了解返回数据的格式,将结果复制到 JSON 格式化服务,例如 https://jsonformatter.curiousconcept.com/
然后您会发现返回的数据中有 多个 位艺术家,这就是为什么它不像 "albums by artist"
那么简单
我猜 "length" 数据以毫秒为单位。
首发:
Is there any way of getting a list of albums for an artist (band), along with a link to album art and runtime?
是的,绝对是。
首先,您需要找到创作波西米亚狂想曲的艺术家,例如女王。他们被标识为 MusicBrainz 艺术家 ID“0383dadf-2a4e-4d10-a46a-e9e041da8eb3", so you can do a browse request for Releases by this artist: https://musicbrainz.org/ws/2/release/?artist=0383dadf-2a4e-4d10-a46a-e9e041da8eb3&inc=recordings&fmt=json(注意 inc=recordings
)
这可以满足您的大部分需求。发布列表及其运行时——有点像。每个版本都应该有一个或多个 medium
属性,而这些属性又具有 track-list
和多个 track
。每个 track
的 length
的总和构成了运行时间(length
以毫秒为单位)。
对于封面艺术,您可能会注意到输出有一个 cover-art-archive
属性。对于封面艺术,MusicBrainz 使用 Cover Art Archive which uses MusicBrainz IDs as identifiers. The cover-art-archive
attribute states whether any cover art exists in Cover Art Archive and a few details about this—e.g., does CAA have any images at all (artwork
)? Does it have a back image (back
) and/or a front image (front
)? How many images are there in all for the release (count
)? If the cover-art-archive
→artwork
is true
, we can go on and fetch cover art from the CAA. The CAA's API is really simple: to get the "front" image of a release, say the 1974 UK single "Killer Queen" that has MusicBrainz Release ID "a2d12ee8-9aeb-4d91-bfab-5c21f7a577fc", you can simply do https://coverartarchive.org/release/a2d12ee8-9aeb-4d91-bfab-5c21f7a577fc/front
您还可以执行 https://coverartarchive.org/release/a2d12ee8-9aeb-4d91-bfab-5c21f7a577fc 以获得 JSON 文档,其中包含有关可用封面艺术图像的更多详细信息(例如,这幅图像有两张图像:一张正面+中等图像和一张背面+中等图像)。
封面艺术档案 API 记录在 https://musicbrainz.org/doc/Cover_Art_Archive/API and the MusicBrainz API/web service documentation can be found at https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2
请注意,使用浏览请求,您可以使用 offset
对结果进行分页,并使用 limit
改变每个查询的结果数量,请参阅浏览请求部分下的 "Paging" section MusicBrainz WS 文档。
其次:虽然您没有直接询问这个问题,但您在问题中使用了使用通用术语的搜索查询,所以我想我会稍微谈谈这个问题。在 MusicBrainz 中,所有内容都使用 MusicBrainz identifiers (IDs) 进行标识。 (我也在第一部分提到过它们。)
原因是很多很多名字都不是唯一的。在撰写本文时,MusicBrainz 中有三位被称为 "Queen" 的独特艺术家:https://musicbrainz.org/search?query=%22queen%22&type=artist&method=advanced – not counting any of the 321 other artists that have "queen" as part of their name. Without more information, it is not possible for MusicBrainz to know which of them you want to find out information from, so your first step will likely be to somehow either narrow the search (e.g., add type:group
narrows the search to 123 results, using country:gb
limits to 21 results, doing both gives 11 results (see the search syntax documentation 了解更多详情))或之后以某种方式过滤。
将范围缩小到所需的特定艺术家后,您可以继续执行上述步骤以获取所需的详细信息。缩小范围的步骤将取决于您的具体 application/use 案例。
最后:对于 MusicBrainz 的数据结构,您似乎在抽象层面上缺少一些理解。例如,以上所有假设您所说的专辑是指像 1974 年英国 "Killer Queen" 单曲这样的特定发行版本,而不是像 "Killer Queen" 单曲的任何版本那样更通用的发行概念,它在 MusicBrainz 术语中将是一个 Release Group。
https://musicbrainz.org/doc/MusicBrainz_Entity 是 MusicBrainz 中使用的实体列表。了解发行组和发行版之间以及曲目和录音(以及作品)之间的差异将使您能够更好地有效地使用 Web 服务和一般的 MusicBrainz 数据。
https://musicbrainz.org/doc/MusicBrainz_Database/Schema 介绍了 MusicBrainz 的结构。了解艺术家来源、("advanced") 关系和媒介如何影响事物也可能让您以后省去很多麻烦。
有没有办法获取艺术家(乐队)的专辑列表,以及 link 专辑封面和运行时间?
我得到了这个端点,但它 returns 的数据令人困惑: http://musicbrainz.org/ws/2/recording?query=artist:%22Queen%22%20and%20type:album&fmt=json
数据并不是真正围绕专辑组织的,"length" 数据 returns 大约是 203000。但是如果你在上下文中看到它会更好,所以这是它的第一部分(抱歉,我无法缩进):
{
"created": "2018-02-17T03:47:57.052Z",
"count": 9533710,
"offset": 0,
"recordings": [
{
"id": "c2e919f7-ecb9-4fdf-9162-3c26d0127fa0",
"score": "100",
"title": "Son and Daughter",
"length": 203000,
"video": null,
"artist-credit": [
{
"artist": {
"id": "0383dadf-2a4e-4d10-a46a-e9e041da8eb3",
"name": "Queen",
"sort-name": "Queen",
"disambiguation": "UK rock group",
"aliases": [
{
"sort-name": "Queen + Adam Lambert",
"name": "Queen + Adam Lambert",
"locale": null,
"type": null,
"primary": null,
"begin-date": "2011",
"end-date": null
}
]
}
}
],
"releases": [
{
"id": "bb19abaf-80b3-4a3e-846d-5f12b12af827",
"title": "Queen",
"status": "Official",
"release-group": {
"id": "810068af-2b3c-3e9c-b2ab-68a3f3e3787d",
"primary-type": "Album"
},
"date": "1994",
"country": "NL",
"release-events": [
{
"date": "1994",
"area": {
"id": "ef1b7cc0-cd26-36f4-8ea0-04d9623786c7",
"name": "Netherlands",
"sort-name": "Netherlands",
"iso-3166-1-codes": [
"NL"
]
}
}
],
"track-count": 10,
"media": [
{
"position": 1,
"format": "CD",
"track": [
{
"id": "3a26455e-2660-30dc-a652-6a2b40f1fbe5",
"number": "8",
"title": "Son and Daughter",
"length": 203400
}
],
"track-count": 10,
"track-offset": 7
}
]
},
{
"id": "1783da6a-9315-3602-a488-1738eb733a0f",
"title": "Queen",
"status": "Official",
"release-group": {
"id": "810068af-2b3c-3e9c-b2ab-68a3f3e3787d",
"primary-type": "Album"
},
"date": "1973-09-04",
"country": "US",
"release-events": [
{
"date": "1973-09-04",
"area": {
"id": "489ce91b-6658-3307-9877-795b68554c98",
"name": "United States",
"sort-name": "United States",
"iso-3166-1-codes": [
"US"
]
}
}
],
如果有人能向我解释这些数据,那么我就不需要另一个端点了。但我一直在寻找 musicbrainz 文档,但它们并不是很有帮助。
最好是一次调用,但如果需要我可以连续调用。
感谢您的帮助。
您需要了解返回数据的格式,将结果复制到 JSON 格式化服务,例如 https://jsonformatter.curiousconcept.com/
然后您会发现返回的数据中有 多个 位艺术家,这就是为什么它不像 "albums by artist"
那么简单我猜 "length" 数据以毫秒为单位。
首发:
Is there any way of getting a list of albums for an artist (band), along with a link to album art and runtime?
是的,绝对是。
首先,您需要找到创作波西米亚狂想曲的艺术家,例如女王。他们被标识为 MusicBrainz 艺术家 ID“0383dadf-2a4e-4d10-a46a-e9e041da8eb3", so you can do a browse request for Releases by this artist: https://musicbrainz.org/ws/2/release/?artist=0383dadf-2a4e-4d10-a46a-e9e041da8eb3&inc=recordings&fmt=json(注意 inc=recordings
)
这可以满足您的大部分需求。发布列表及其运行时——有点像。每个版本都应该有一个或多个 medium
属性,而这些属性又具有 track-list
和多个 track
。每个 track
的 length
的总和构成了运行时间(length
以毫秒为单位)。
对于封面艺术,您可能会注意到输出有一个 cover-art-archive
属性。对于封面艺术,MusicBrainz 使用 Cover Art Archive which uses MusicBrainz IDs as identifiers. The cover-art-archive
attribute states whether any cover art exists in Cover Art Archive and a few details about this—e.g., does CAA have any images at all (artwork
)? Does it have a back image (back
) and/or a front image (front
)? How many images are there in all for the release (count
)? If the cover-art-archive
→artwork
is true
, we can go on and fetch cover art from the CAA. The CAA's API is really simple: to get the "front" image of a release, say the 1974 UK single "Killer Queen" that has MusicBrainz Release ID "a2d12ee8-9aeb-4d91-bfab-5c21f7a577fc", you can simply do https://coverartarchive.org/release/a2d12ee8-9aeb-4d91-bfab-5c21f7a577fc/front
您还可以执行 https://coverartarchive.org/release/a2d12ee8-9aeb-4d91-bfab-5c21f7a577fc 以获得 JSON 文档,其中包含有关可用封面艺术图像的更多详细信息(例如,这幅图像有两张图像:一张正面+中等图像和一张背面+中等图像)。
封面艺术档案 API 记录在 https://musicbrainz.org/doc/Cover_Art_Archive/API and the MusicBrainz API/web service documentation can be found at https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2
请注意,使用浏览请求,您可以使用 offset
对结果进行分页,并使用 limit
改变每个查询的结果数量,请参阅浏览请求部分下的 "Paging" section MusicBrainz WS 文档。
其次:虽然您没有直接询问这个问题,但您在问题中使用了使用通用术语的搜索查询,所以我想我会稍微谈谈这个问题。在 MusicBrainz 中,所有内容都使用 MusicBrainz identifiers (IDs) 进行标识。 (我也在第一部分提到过它们。)
原因是很多很多名字都不是唯一的。在撰写本文时,MusicBrainz 中有三位被称为 "Queen" 的独特艺术家:https://musicbrainz.org/search?query=%22queen%22&type=artist&method=advanced – not counting any of the 321 other artists that have "queen" as part of their name. Without more information, it is not possible for MusicBrainz to know which of them you want to find out information from, so your first step will likely be to somehow either narrow the search (e.g., add type:group
narrows the search to 123 results, using country:gb
limits to 21 results, doing both gives 11 results (see the search syntax documentation 了解更多详情))或之后以某种方式过滤。
将范围缩小到所需的特定艺术家后,您可以继续执行上述步骤以获取所需的详细信息。缩小范围的步骤将取决于您的具体 application/use 案例。
最后:对于 MusicBrainz 的数据结构,您似乎在抽象层面上缺少一些理解。例如,以上所有假设您所说的专辑是指像 1974 年英国 "Killer Queen" 单曲这样的特定发行版本,而不是像 "Killer Queen" 单曲的任何版本那样更通用的发行概念,它在 MusicBrainz 术语中将是一个 Release Group。
https://musicbrainz.org/doc/MusicBrainz_Entity 是 MusicBrainz 中使用的实体列表。了解发行组和发行版之间以及曲目和录音(以及作品)之间的差异将使您能够更好地有效地使用 Web 服务和一般的 MusicBrainz 数据。
https://musicbrainz.org/doc/MusicBrainz_Database/Schema 介绍了 MusicBrainz 的结构。了解艺术家来源、("advanced") 关系和媒介如何影响事物也可能让您以后省去很多麻烦。