diff --git a/.env b/.env index 4840fddb..3d21d5fe 100644 --- a/.env +++ b/.env @@ -8,4 +8,5 @@ API_KEY_MOVIEDB= API_TOKEN_READWISE= SECRET_FEED_ALBUM_RELEASES= COOKIE_STORYGRAPH= -LISTENBRAINZ_TOKEN= \ No newline at end of file +LISTENBRAINZ_TOKEN= +ACCOUNT_ID_PLEX = \ No newline at end of file diff --git a/api/scrobble.js b/api/scrobble.js index 4f2c9646..1c669674 100644 --- a/api/scrobble.js +++ b/api/scrobble.js @@ -1,8 +1,30 @@ import { getStore } from '@netlify/blobs' export default async (request, context) => { - console.log(request) - console.log(context) + const ACCOUNT_ID_PLEX = Netlify.env.get("ACCOUNT_ID_PLEX"); + const id = params.get('id') + const params = new URL(request['url']).searchParams + const data = await request.formData() + const payload = data['payload'] + console.log(data) + console.log(payload) + + if (!id) return new Response(JSON.stringify({ + status: 'Bad request', + }), + { headers: { "Content-Type": "application/json" } } + ) + + if (id !== ACCOUNT_ID_PLEX) return new Response(JSON.stringify({ + status: 'Forbidden', + }), + { headers: { "Content-Type": "application/json" } } + ) + + if (payload?.event === 'media.scrobble') { + console.log('scrobble') + } + return new Response(JSON.stringify({ status: 'success', }), diff --git a/src/_data/json/mbid-patches.js b/src/_data/json/mbid-patches.js index 579f9c44..30cbda95 100644 --- a/src/_data/json/mbid-patches.js +++ b/src/_data/json/mbid-patches.js @@ -3,6 +3,7 @@ export default { 'aesop rock': 'aba64937-3334-4c65-90a1-4e6b9d4d7ada', afi: '1c3919b2-43ca-4a4a-935d-9d50135ec0ef', aset: '5dac39d3-beb8-4c99-9cdc-3e647a594af6', + ataraxy: 'f17a2c62-51cf-4e7e-9640-a5da5b1178a3', augury: 'd651baba-5ce1-4315-b884-d951e0435418', autopsy: '1d097d38-d5ca-4cd4-9200-7f08eedd0875', basement: 'a8c7ff7a-ebc0-42c7-8828-475decf0ccdd',