chore: scrobbling

This commit is contained in:
Cory Dransfeldt 2024-03-29 21:55:58 -07:00
parent 7d947521f7
commit 72b33002f0
No known key found for this signature in database

View file

@ -100,7 +100,7 @@ export default async (request) => {
const artistObj = {
mbid,
genre,
image: `https://cdn.coryd.dev/artists/${encodeURIComponent(sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase())}.jpg`
image: `https://cdn.coryd.dev/artists/${sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase()}.jpg`
}
artistInfo = artistObj
await artists.setJSON(artistKey, artistObj)
@ -108,14 +108,12 @@ export default async (request) => {
// if there is no album blob, populate one
if (!albumInfo) {
console.log(`https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=${MUSIC_KEY}&artist=${encodeURIComponent(sanitizeMediaString(artist).replace(/\s+/g, '+').toLowerCase())}&album=${encodeURIComponent(sanitizeMediaString(album).replace(/\s+/g, '+').toLowerCase())}&format=json`)
const albumRes = await fetch(
`https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=${MUSIC_KEY}&artist=${encodeURIComponent(sanitizeMediaString(artist).replace(/\s+/g, '+').toLowerCase())}&album=${encodeURIComponent(sanitizeMediaString(album).replace(/\s+/g, '+').toLowerCase())}&format=json`,
`https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=${MUSIC_KEY}&artist=${sanitizeMediaString(artist).replace(/\s+/g, '+').toLowerCase()}&album=${sanitizeMediaString(album).replace(/\s+/g, '+').toLowerCase()}&format=json`,
{
type: "json",
}
).then((data) => {
console.log(data)
if (data.ok) return data.json()
throw new Error('Something went wrong with the Last.fm endpoint.');
}).catch(err => {