data endpoint for entity 90008 (aka. a website)

use cover from coverartarchive if releaseMbId is available

ptr.pet 7f61f12b cb9e8adb

verified
0/0
Waiting for spindle ...
Changed files
+8 -2
src
lib
routes
(site)
+6 -2
src/lib/lastfm.ts
··· 8 8 type LastTrack = { 9 9 name: string; 10 10 artist: string; 11 + album: string; 11 12 image: string | null; 12 13 link: string | null; 13 14 when: number; ··· 25 26 } 26 27 }; 27 28 28 - const getTrackCoverArt = (originUrl: string | null | undefined) => { 29 + const getTrackCoverArt = (releaseMbId: string | null | undefined, originUrl: string | null | undefined) => { 30 + if (releaseMbId) return `https://coverartarchive.org/release/${releaseMbId}/front-250`; 31 + 29 32 if (!originUrl) return null; 30 33 let videoId: string | null = null; 31 34 ··· 93 96 const data: LastTrack = { 94 97 name: track.trackName, 95 98 artist: joinArtists(track.artists) ?? 'Unknown Artist', 96 - image: getTrackCoverArt(track.originUrl), 99 + album: track.releaseName ?? 'Unknown Album', 100 + image: getTrackCoverArt(track.releaseMbId, track.originUrl), 97 101 link: track.originUrl ?? null, 98 102 when: when, 99 103 status: status
+2
src/routes/(site)/+page.svelte
··· 160 160 class="border-4 w-[4.5rem] h-[4.5rem] object-cover" 161 161 style="border-style: none double none none;" 162 162 src={data.lastTrack.image} 163 + title={data.lastTrack.album} 163 164 /> 164 165 {:else} 165 166 <img 166 167 class="border-4 w-[4.5rem] h-[4.5rem] p-2" 167 168 style="border-style: none double none none; image-rendering: pixelated;" 168 169 src="/icons/cd_audio.webp" 170 + title={data.lastTrack.album} 169 171 /> 170 172 {/if} 171 173 <div class="flex flex-col max-w-[60ch] p-2">