chore: improve musicbrainz links
This commit is contained in:
parent
336ab14981
commit
23a0aec76a
3 changed files with 11 additions and 3 deletions
|
@ -123,6 +123,12 @@ export default async () => {
|
||||||
const track = trackData['recenttracks']['track'][0]
|
const track = trackData['recenttracks']['track'][0]
|
||||||
const mbid = track['artist']['mbid']
|
const mbid = track['artist']['mbid']
|
||||||
let genre = ''
|
let genre = ''
|
||||||
|
const artistUrl = mbid
|
||||||
|
? `https://musicbrainz.org/artist/${mbid}`
|
||||||
|
: `https://musicbrainz.org/search?query=${track['artist']['#text'].replace(
|
||||||
|
/\s+/g,
|
||||||
|
'+'
|
||||||
|
)}&type=artist`
|
||||||
|
|
||||||
if (mbid && mbid !== '') {
|
if (mbid && mbid !== '') {
|
||||||
const genreUrl = `https://musicbrainz.org/ws/2/artist/${mbid}?inc=aliases+genres&fmt=json`
|
const genreUrl = `https://musicbrainz.org/ws/2/artist/${mbid}?inc=aliases+genres&fmt=json`
|
||||||
|
@ -136,7 +142,7 @@ export default async () => {
|
||||||
return Response.json({
|
return Response.json({
|
||||||
content: `${emojiMap(genre, track['artist']['#text'])} <a href="${track['url']}">${
|
content: `${emojiMap(genre, track['artist']['#text'])} <a href="${track['url']}">${
|
||||||
track['name']
|
track['name']
|
||||||
} by ${track['artist']['#text']}</a>`,
|
}</a> by <a href="${artistUrl}">${track['artist']['#text']}</a>`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,9 @@ module.exports = async function () {
|
||||||
.toLowerCase()}.jpg`,
|
.toLowerCase()}.jpg`,
|
||||||
url: album['mbid']
|
url: album['mbid']
|
||||||
? `https://musicbrainz.org/album/${album['mbid']}`
|
? `https://musicbrainz.org/album/${album['mbid']}`
|
||||||
: `https://musicbrainz.org/search?query=${encodeURI(album['name'])}&type=release_group`,
|
: `https://musicbrainz.org/taglookup/index?tag-lookup.artist=${album['artist'][
|
||||||
|
'name'
|
||||||
|
].replace(/\s+/g, '+')}&tag-lookup.release=${album['name'].replace(/\s+/g, '+')}`,
|
||||||
type: 'album',
|
type: 'album',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -18,7 +18,7 @@ module.exports = async function () {
|
||||||
'https://cdn.coryd.dev/artists/missing-artist.jpg',
|
'https://cdn.coryd.dev/artists/missing-artist.jpg',
|
||||||
url: artist['mbid']
|
url: artist['mbid']
|
||||||
? `https://musicbrainz.org/artist/${artist['mbid']}`
|
? `https://musicbrainz.org/artist/${artist['mbid']}`
|
||||||
: `https://musicbrainz.org/search?query=${encodeURI(artist['name'])}&type=artist`,
|
: `https://musicbrainz.org/search?query=${artist['name'].replace(/\s+/g, '+')}&type=artist`,
|
||||||
type: 'artist',
|
type: 'artist',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Reference in a new issue