From 6f59b86be8293920880f5c5f7a6638199fc3f95c Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Tue, 7 May 2024 17:44:22 -0700 Subject: [PATCH] chore: debug --- api/scrobble.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/api/scrobble.js b/api/scrobble.js index ac2fe8f5..36b8fef9 100644 --- a/api/scrobble.js +++ b/api/scrobble.js @@ -19,9 +19,9 @@ export default async (request) => { const payload = JSON.parse(data.get('payload')) if (payload?.event === 'media.scrobble') { - const artist = payload.Metadata.grandparentTitle - const album = payload.Metadata.parentTitle - const track = payload.Metadata.title + const artist = payload['Metadata']['grandparentTitle'] + const album = payload['Metadata']['parentTitle'] + const track = payload['Metadata']['title'] const listenedAt = DateTime.now().toSeconds() const artistKey = sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase() const albumKey = `${artistKey}-${sanitizeMediaString(album).replace(/\s+/g, '-').toLowerCase()}` @@ -54,6 +54,16 @@ export default async (request) => { return new Response(JSON.stringify({ status: 'error', message: albumError.message }), { headers: { "Content-Type": "application/json" } }) } + console.log('### TRACK INSERT') + console.log({ + artist_name: artist, + album_name: album, + track_name: track, + listened_at: listenedAt, + album_key: albumKey + }) + console.log('### TRACK INSERT') + const { error: listenError } = await supabase.from('listens').insert([ { artist_name: artist,