From 8d6d9481c2d4d8947fbc037f522740f3ccbdd630 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 14 Jan 2026 16:30:06 +0200 Subject: [PATCH] debug --- index.js | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 9d80f91..0ac56ca 100644 --- a/index.js +++ b/index.js @@ -3,11 +3,11 @@ import fetch from 'node-fetch'; const botBearerFile = process.env.BOT_BEARER_FILE; const userBearerFile = process.env.USER_BEARER_FILE; -const instance = process.env.INSTANCE; +const instance = process.env.INSTANCE || 'shigusegubu.club'; const videoId = process.env.VIDEO_ID; -const botBearer = fs.readFileSync(botBearerFile, 'utf-8'); -const userBearer = fs.readFileSync(userBearerFile, 'utf-8'); +// const botBearer = fs.readFileSync(botBearerFile, 'utf-8'); +// const userBearer = fs.readFileSync(userBearerFile, 'utf-8'); const globalState = { exit: false, @@ -15,13 +15,54 @@ const globalState = { }; const headers = (bearer) => ({ - accept: '*/*', + accept: 'application/json', authorization: `Bearer ${bearer.trim()}`, 'cache-control': 'no-cache', 'content-type': 'application/json', pragma: 'no-cache', }); +/* +const app = await fetch(`https://${instance}/api/v1/apps`, { + headers: { + accept: 'application/json', + 'cache-control': 'no-cache', + 'content-type': 'application/json', + pragma: 'no-cache', + }, + body: JSON.stringify({ + client_name: 'HJ Stream Bot', + redirect_uris: 'urn:ietf:wg:oauth:2.0:oob', + scopes: 'write:scrobbles', + }), + method: 'POST', + mode: 'cors', +}) +/* */ +// console.log('APP REG STATUS', app.status) +//const { client_id, client_secret } = await app.json() +//console.log({ client_id, client_secret }) + +/* */ +const bearer = await fetch(`https://${instance}/oauth/token`, { + headers: { + accept: 'application/json', + 'cache-control': 'no-cache', + 'content-type': 'application/json', + pragma: 'no-cache', + }, + body: JSON.stringify({ + client_id, + client_secret, + grant_type: 'client_credentials', + }), + method: 'POST', + mode: 'cors', +}) +console.log('TOKEN STATUS', bearer.status) +console.log('TOKEN RESPONSE', await bearer.json()) +/* */ + const post = ({ status, spoiler_text,