diff --git a/netlify/edge-functions/now-playing.js b/netlify/edge-functions/now-playing.js
index 1a19156f..142c5aad 100644
--- a/netlify/edge-functions/now-playing.js
+++ b/netlify/edge-functions/now-playing.js
@@ -54,30 +54,45 @@ export default async () => {
if (traktRes['type'] === 'episode') {
return Response.json({
text: `📺 ${traktRes['show']['title']} • ${traktRes['episode']['title']}`,
+ html: `📺 ${traktRes['show']['title']} • ${traktRes['episode']['title']}`,
})
}
if (traktRes['type'] === 'movie') {
return Response.json({
text: `🎥 ${traktRes['movie']['title']}`,
+ html: `🎥 ${traktRes['movie']['title']}`,
})
}
}
- const trackRes = await fetch('https://api.music.apple.com/v1/me/recent/played/tracks?limit=1', {
- headers: {
- 'Content-Type': 'application/json',
- Authorization: `Bearer ${API_APPLE_MUSIC_DEVELOPER_TOKEN}`,
- 'music-user-token': `${API_APPLE_MUSIC_USER_TOKEN}`,
- },
- })
+ const trackRes = await fetch(
+ 'https://api.music.apple.com/v1/me/recent/played/tracks?limit=1&extend=artistUrl',
+ {
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${API_APPLE_MUSIC_DEVELOPER_TOKEN}`,
+ 'music-user-token': `${API_APPLE_MUSIC_USER_TOKEN}`,
+ },
+ }
+ )
.then((data) => data.json())
.catch()
const track = trackRes.data?.[0]['attributes']
+ const trackUrl = track['url']
+ ? track['url']
+ : `https://musicbrainz.org/taglookup/index?tag-lookup.artist=${track['artistName'].replace(
+ /\s+/g,
+ '+'
+ )}&tag-lookup.track=${track['name'].replace(/\s+/g, '+')}`
const artist = aliasArtist(track['artistName'])
+ const artistUrl = track['artistUrl']
+ ? track['artistUrl']
+ : `https://musicbrainz.org/search?query=${track['artistName'].replace(/\s+/g, '+')}&type=artist`
return Response.json({
text: `🎧 ${track['name']} by ${artist}`,
+ html: `🎧 ${track['name']} by ${artist}`,
})
}
diff --git a/src/assets/scripts/script.js b/src/assets/scripts/script.js
index 37a1aff6..10a84062 100644
--- a/src/assets/scripts/script.js
+++ b/src/assets/scripts/script.js
@@ -7,7 +7,7 @@
const populateNowPlaying = (data) => {
loading.style.display = 'none'
- content.innerText = data.text
+ content.innerHTML = data.html
content.classList.remove('hidden')
}