chore: debug

This commit is contained in:
Cory Dransfeldt 2024-05-07 17:44:22 -07:00
parent 4d80761b22
commit 6f59b86be8
No known key found for this signature in database

View file

@ -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,