chore: debug
This commit is contained in:
parent
4d80761b22
commit
6f59b86be8
1 changed files with 13 additions and 3 deletions
|
@ -19,9 +19,9 @@ export default async (request) => {
|
||||||
const payload = JSON.parse(data.get('payload'))
|
const payload = JSON.parse(data.get('payload'))
|
||||||
|
|
||||||
if (payload?.event === 'media.scrobble') {
|
if (payload?.event === 'media.scrobble') {
|
||||||
const artist = payload.Metadata.grandparentTitle
|
const artist = payload['Metadata']['grandparentTitle']
|
||||||
const album = payload.Metadata.parentTitle
|
const album = payload['Metadata']['parentTitle']
|
||||||
const track = payload.Metadata.title
|
const track = payload['Metadata']['title']
|
||||||
const listenedAt = DateTime.now().toSeconds()
|
const listenedAt = DateTime.now().toSeconds()
|
||||||
const artistKey = sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase()
|
const artistKey = sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase()
|
||||||
const albumKey = `${artistKey}-${sanitizeMediaString(album).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" } })
|
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([
|
const { error: listenError } = await supabase.from('listens').insert([
|
||||||
{
|
{
|
||||||
artist_name: artist,
|
artist_name: artist,
|
||||||
|
|
Reference in a new issue