files
This commit is contained in:
parent
6695abc4e4
commit
604b617c52
1 changed files with 14 additions and 10 deletions
24
index.js
24
index.js
|
|
@ -1,10 +1,14 @@
|
|||
import fs from 'node:fs';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
const botBearer = process.env.BOT_BEARER;
|
||||
const userBearer = process.env.USER_BEARER;
|
||||
const botBearerFile = process.env.BOT_BEARER_FILE;
|
||||
const userBearerFile = process.env.USER_BEARER_FILE;
|
||||
const instance = process.env.INSTANCE;
|
||||
const videoId = process.env.VIDEO_ID;
|
||||
|
||||
const botBearer = fs.readFileSync(botBearerFile, 'utf-8');
|
||||
const userBearer = fs.readFileSync(userBearerFile, 'utf-8');
|
||||
|
||||
const globalState = {
|
||||
exit: false,
|
||||
currentlyLive: false,
|
||||
|
|
@ -68,16 +72,16 @@ const loop = async () => {
|
|||
);
|
||||
const { state } = await response.json();
|
||||
const isLive = state.id === 1; // published
|
||||
console.info('Live: ', isLive, globalState.currentlyLive)
|
||||
console.info('Live: ', isLive, globalState.currentlyLive);
|
||||
const stateChange = isLive !== globalState.currentlyLive;
|
||||
console.info('State change', stateChange)
|
||||
console.info('State change', stateChange);
|
||||
globalState.currentlyLive = isLive;
|
||||
|
||||
console.info('State: ', state)
|
||||
console.info('State: ', state);
|
||||
if (stateChange) {
|
||||
if (isLive) {
|
||||
console.info('Went live!')
|
||||
console.info(process.env)
|
||||
console.info('Went live!');
|
||||
console.info(process.env);
|
||||
const postResult = await post({
|
||||
spoiler_text: 'Stream announcment',
|
||||
status: [
|
||||
|
|
@ -87,15 +91,15 @@ const loop = async () => {
|
|||
].join('\n'),
|
||||
visibility: 'public',
|
||||
});
|
||||
console.info(postResult)
|
||||
console.info(postResult);
|
||||
|
||||
const scrobbleResult = await scrobble({
|
||||
title: 'Streaming on PeerTube',
|
||||
external_link: `https://tube.ebin.club/w/${videoId}`,
|
||||
});
|
||||
console.info(scrobbleResult)
|
||||
console.info(scrobbleResult);
|
||||
} else {
|
||||
console.info('Went offline...')
|
||||
console.info('Went offline...');
|
||||
await scrobble({
|
||||
title: 'Stream over',
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue