fix: search for artists because rym urls are inconsistent
This commit is contained in:
parent
8d33b78889
commit
38d686a31c
2 changed files with 6 additions and 2 deletions
|
@ -95,9 +95,11 @@ module.exports = async function () {
|
|||
const formattedArtist = titleCase(aliasArtist(track.attributes['artistName']))
|
||||
const formattedAlbum = titleCase(sanitizeMedia(track.attributes['albumName']))
|
||||
const formattedTrack = sanitizeMedia(track.attributes['name'])
|
||||
|
||||
if (!charts.artists[formattedArtist]) {
|
||||
charts.artists[formattedArtist] = {
|
||||
artist: formattedArtist,
|
||||
url: `https://rateyourmusic.com/search?searchterm=${encodeURI(formattedArtist)}`,
|
||||
plays: 1,
|
||||
}
|
||||
} else {
|
||||
|
@ -111,7 +113,9 @@ module.exports = async function () {
|
|||
art: track.attributes.artwork.url.replace('{w}', '300').replace('{h}', '300'),
|
||||
url: track['relationships']
|
||||
? `https://song.link/${track['relationships'].albums.data.pop().attributes.url}`
|
||||
: `https://rateyourmusic.com/search?searchtype=l&searchterm=${formattedAlbum}%20${formattedArtist}`,
|
||||
: `https://rateyourmusic.com/search?searchtype=l&searchterm=${encodeURI(
|
||||
formattedAlbum
|
||||
)}%20${encodeURI(formattedArtist)}`,
|
||||
plays: 1,
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</h2>
|
||||
<div class="grid grid-cols-2 gap-2 md:grid-cols-4 not-prose">
|
||||
{% for artist in music.artists %}
|
||||
<a href="https://rateyourmusic.com/artist/{{ artist.artist | dashLower }}" title="{{artist.artist | escape}}">
|
||||
<a href="{{ artist.url }}" title="{{artist.artist | escape}}">
|
||||
<div class="relative block">
|
||||
<div class="absolute left-0 top-0 h-full w-full rounded-lg border border-purple-600 hover:border-purple-500 bg-cover-gradient dark:border-purple-400 dark:hover:border-purple-500"></div>
|
||||
<div class="absolute left-1 bottom-2 drop-shadow-md">
|
||||
|
|
Reference in a new issue