debug
This commit is contained in:
parent
89fc6b3e74
commit
8d6d9481c2
1 changed files with 45 additions and 4 deletions
49
index.js
49
index.js
|
|
@ -3,11 +3,11 @@ import fetch from 'node-fetch';
|
||||||
|
|
||||||
const botBearerFile = process.env.BOT_BEARER_FILE;
|
const botBearerFile = process.env.BOT_BEARER_FILE;
|
||||||
const userBearerFile = process.env.USER_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 videoId = process.env.VIDEO_ID;
|
||||||
|
|
||||||
const botBearer = fs.readFileSync(botBearerFile, 'utf-8');
|
// const botBearer = fs.readFileSync(botBearerFile, 'utf-8');
|
||||||
const userBearer = fs.readFileSync(userBearerFile, 'utf-8');
|
// const userBearer = fs.readFileSync(userBearerFile, 'utf-8');
|
||||||
|
|
||||||
const globalState = {
|
const globalState = {
|
||||||
exit: false,
|
exit: false,
|
||||||
|
|
@ -15,13 +15,54 @@ const globalState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const headers = (bearer) => ({
|
const headers = (bearer) => ({
|
||||||
accept: '*/*',
|
accept: 'application/json',
|
||||||
authorization: `Bearer ${bearer.trim()}`,
|
authorization: `Bearer ${bearer.trim()}`,
|
||||||
'cache-control': 'no-cache',
|
'cache-control': 'no-cache',
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
pragma: 'no-cache',
|
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 = ({
|
const post = ({
|
||||||
status,
|
status,
|
||||||
spoiler_text,
|
spoiler_text,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue