From d3f7ac8533bf5435a657a1642d39166f924f8097 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Fri, 29 Mar 2024 15:12:34 -0700 Subject: [PATCH] chore: scrobbling --- api/scrobble.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/scrobble.js b/api/scrobble.js index 7838eae7..61a6250f 100644 --- a/api/scrobble.js +++ b/api/scrobble.js @@ -101,7 +101,8 @@ export default async (request) => { // scrobble logic artistInfo = await artists.get(artistKey, { type: 'json'}) - console.log(artistInfo?.['mbid']) + console.log(artistInfo) + console.log(typeof artistInfo) const artistUrl = `https://musicbrainz.org/artist/${artistInfo?.['mbid']}` const trackScrobbleData = { track, @@ -126,8 +127,9 @@ export default async (request) => { if (!scrobbleUpdate['data']) scrobbleUpdate = { data: [trackScrobbleData] } if (windowData['data']) windowUpdate['data'].push(trackScrobbleData) if (!windowData['data']) windowUpdate = { data: [trackScrobbleData] } + windowUpdate = { data: filterOldScrobbles(windowUpdate.data) } await scrobbles.setJSON(`${weekStop()}`, JSON.stringify(scrobbleUpdate)) - await scrobbles.setJSON('window', JSON.stringify(filterOldScrobbles(windowUpdate.data))) + await scrobbles.setJSON('window', JSON.stringify(windowUpdate)) } return new Response(JSON.stringify({