meme refinery
This commit is contained in:
@@ -460,7 +460,7 @@
|
||||
"filePath": "Y:\\media\\videos\\ALttP\\my-vids\\personal-bests\\100%-mg-ahp\\2017-12-22-100mg-11912.mp4",
|
||||
"sceneItem": "16x9ph",
|
||||
"length": 4786,
|
||||
"includeInShuffle": true
|
||||
"includeInShuffle": false
|
||||
},
|
||||
{
|
||||
"id": "pb-ab",
|
||||
@@ -482,7 +482,7 @@
|
||||
"filePath": "Y:\\media\\videos\\ALttP\\my-vids\\personal-bests\\all-dungeons\\2017-11-19-ad-11459.mp4",
|
||||
"sceneItem": "16x9ph",
|
||||
"length": 4555,
|
||||
"includeInShuffle": true
|
||||
"includeInShuffle": false
|
||||
},
|
||||
{
|
||||
"id": "pb-any-nmg",
|
||||
@@ -493,7 +493,7 @@
|
||||
"filePath": "Y:\\media\\videos\\ALttP\\my-vids\\personal-bests\\any%-nmg-nsq\\2018-05-27-nmg-12624.mp4",
|
||||
"sceneItem": "16x9ph",
|
||||
"length": 5190,
|
||||
"includeInShuffle": true
|
||||
"includeInShuffle": false
|
||||
},
|
||||
{
|
||||
"id": "pb-any-no-eg",
|
||||
@@ -526,7 +526,7 @@
|
||||
"filePath": "Y:\\media\\videos\\ALttP\\my-vids\\personal-bests\\mirror-shield\\2017-06-20-mirror-shield-5032.mp4",
|
||||
"sceneItem": "16x9ph",
|
||||
"length": 3068,
|
||||
"includeInShuffle": true
|
||||
"includeInShuffle": false
|
||||
},
|
||||
{
|
||||
"id": "pb-ms-no-eg",
|
||||
@@ -548,7 +548,7 @@
|
||||
"filePath": "Y:\\media\\videos\\ALttP\\my-vids\\personal-bests\\rbo\\2017-12-01-rbo-11813.mp4",
|
||||
"sceneItem": "16x9ph",
|
||||
"length": 4725,
|
||||
"includeInShuffle": true
|
||||
"includeInShuffle": false
|
||||
},
|
||||
{
|
||||
"id": "pb-100-nmg",
|
||||
|
||||
110
fgfm.js
110
fgfm.js
@@ -103,43 +103,24 @@ const streamInit = (config, twitch) => {
|
||||
// Also handles "commercial breaks" if enabled
|
||||
const nextVideo = () => {
|
||||
// Show a "commercial break" if it's been long enough since the last one
|
||||
/* let secondsSinceLastCommercial = (Date.now() - state.lastCommercialShownAt) / 1000;
|
||||
let secondsSinceLastCommercial = (Date.now() - state.lastCommercialShownAt) / 1000;
|
||||
if (config.commercialsEnabled === true && secondsSinceLastCommercial >= config.commercialInterval) {
|
||||
state.commercialPlaying = true;
|
||||
|
||||
console.log(`It has been ${secondsSinceLastCommercial} seconds since the last commercial break!`);
|
||||
// Random chance for it to be "everybody wow"
|
||||
let memeId = false;
|
||||
if ((Math.floor(Math.random() * 100) + 1) <= config.auwChance) {
|
||||
console.log(`Showing AUW!`);
|
||||
auw(() => {
|
||||
// show next video in queue once the commercial is done
|
||||
state.lastCommercialShownAt = Date.now();
|
||||
state.commercialPlaying = false;
|
||||
nextVideo();
|
||||
});
|
||||
} else {
|
||||
let commercial = config.vods.memes.sort(util.randSort)[0];
|
||||
console.log(`Showing random meme: ${commercial.name}`);
|
||||
|
||||
let handleCommercialFinish = () => {
|
||||
// unmute songrequest audio
|
||||
twitch.editorChat.say(config.twitch.channel, `!volume ${config.defaultSRVolume}`);
|
||||
|
||||
// update commercial state and show next video in queue
|
||||
state.lastCommercialShownAt = Date.now();
|
||||
state.commercialPlaying = false;
|
||||
nextVideo();
|
||||
};
|
||||
|
||||
obs.playVideoInScene(commercial, config.commercialSceneName, handleCommercialFinish)
|
||||
.then(res => {
|
||||
// mute songrequest audio
|
||||
twitch.editorChat.say(config.twitch.channel, `!volume 0`);
|
||||
});
|
||||
memeId = 'auw';
|
||||
}
|
||||
showMeme(memeId).then(() => {
|
||||
state.lastCommercialShownAt = Date.now();
|
||||
state.commercialPlaying = false;
|
||||
nextVideo();
|
||||
}).catch(console.error);
|
||||
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
// Keep track of recently played videos
|
||||
if (state.recentlyPlayed.length === config.recentlyPlayedMemory) {
|
||||
@@ -147,10 +128,8 @@ const streamInit = (config, twitch) => {
|
||||
}
|
||||
state.recentlyPlayed.push(state.currentVideo.id);
|
||||
|
||||
// If a commercial is playing, wait until it's done
|
||||
while (state.commercialPlaying === true) {
|
||||
//
|
||||
}
|
||||
// If a commercial is playing, wait until it's done to switch
|
||||
while (state.commercialPlaying === true) {}
|
||||
|
||||
// play the next video in the queue, or pick one at random if the queue is empty
|
||||
if (state.videoQueue.length > 0) {
|
||||
@@ -160,16 +139,11 @@ const streamInit = (config, twitch) => {
|
||||
if ((Math.floor(Math.random() * 100) + 1) <= config.roomGrindChance) {
|
||||
console.log(`Room grind selected!`);
|
||||
// show room-grind source
|
||||
// obs.showRoomGrind(config.roomGrindPlaytime);
|
||||
obs.websocket.setSceneItemProperties({"item": "room-grind", "scene-name": config.defaultSceneName, "visible": true})
|
||||
.then(res => {
|
||||
obs.showActivity("NOW SHOWING: TTAS Room Grind !ttas");
|
||||
state.videoTimer = setTimeout(() => {
|
||||
// after timeout, hide room-grind and call nextVideo()
|
||||
obs.websocket.setSceneItemProperties({"item": "room-grind", "scene-name": config.defaultSceneName, "visible": false});
|
||||
nextVideo();
|
||||
}, config.roomGrindPlaytime*1000)
|
||||
});
|
||||
obs.showRoomGrind(config.roomGrindPlaytime, () => {nextVideo()})
|
||||
.then(timer => {
|
||||
videoTimer = timer;
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -188,6 +162,7 @@ const streamInit = (config, twitch) => {
|
||||
state.currentVideo = state.videoQueue.shift();
|
||||
showVideo(state.currentVideo);
|
||||
|
||||
// "Commercials"
|
||||
const showCommercial = (video, callback) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let handleFinish = () => {
|
||||
@@ -206,25 +181,32 @@ const streamInit = (config, twitch) => {
|
||||
});
|
||||
};
|
||||
|
||||
// Everybody OwenWow
|
||||
const auw = (callback) => {
|
||||
// Memes-By-Id
|
||||
const showMeme = (id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// find the vod in memes
|
||||
let video = config.vods.memes.find(e => e.id === 'auw');
|
||||
let video = config.vods.memes.find(e => e.id === id);
|
||||
if (!video) {
|
||||
reject(`No meme found matching ID ${id}`);
|
||||
}
|
||||
|
||||
let handleFinish = () => {
|
||||
// hide owen
|
||||
obs.websocket.setSceneItemProperties({"item": "owen", "scene-name": config.commercialSceneName, "visible": false});
|
||||
// trigger user callback
|
||||
if (typeof callback !== 'undefined') callback();
|
||||
if (id === 'auw') {
|
||||
obs.hide("owen", config.commercialSceneName);
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
|
||||
showCommercial(video, handleFinish)
|
||||
.then(videoHasStarted => {
|
||||
// show owen
|
||||
obs.websocket.setSceneItemProperties({"item": "owen", "scene-name": config.commercialSceneName, "visible": true});
|
||||
// tell chat what's up
|
||||
// in the case of 'auw', show owen + tell chat what's up
|
||||
if (id === 'auw') {
|
||||
obs.show("owen", config.commercialSceneName);
|
||||
twitch.botChat.say(config.twitch.channel, 'Everybody OwenWow');
|
||||
}
|
||||
})
|
||||
.catch(console.error);
|
||||
});
|
||||
};
|
||||
|
||||
// Twitch Chat Commands
|
||||
@@ -322,18 +304,24 @@ const streamInit = (config, twitch) => {
|
||||
// Black Box "Everybody Wow"
|
||||
} else if (commandNoPrefix === 'auw') {
|
||||
state.commercialPlaying = true;
|
||||
auw(() => {
|
||||
state.commercialPlaying = false;
|
||||
});
|
||||
showMeme('auw').then(() => state.commercialPlaying = false).catch(console.error);
|
||||
|
||||
// memes on-demand
|
||||
// Memes on-demand
|
||||
} else if (commandNoPrefix === 'meme') {
|
||||
// @TODO: support request by ID
|
||||
let memeId = commandParts[1] || false;
|
||||
if (memeId) {
|
||||
console.log(`${memeId} meme requested`);
|
||||
if ( config.vods.memes.findIndex(e => e.id === memeId) === -1) {
|
||||
twitch.botChat.say(to, `No meme with that ID exists!`);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
memeId = config.vods.memes.sort(util.randSort)[0].id;
|
||||
console.log(`${memeId} meme randomly selected`);
|
||||
}
|
||||
|
||||
state.commercialPlaying = true;
|
||||
let commercial = config.vods.memes.sort(util.randSort)[0];
|
||||
showCommercial(commercial, () => {
|
||||
state.commercialPlaying = false;
|
||||
});
|
||||
showMeme(memeId).then(() => state.commercialPlaying = false).catch(console.error);
|
||||
|
||||
// SWITCH SCENES
|
||||
} else if (commandNoPrefix === 'switch') {
|
||||
|
||||
45
lib/ghobs.js
45
lib/ghobs.js
@@ -11,7 +11,10 @@ function GHOBS(config) {
|
||||
.then(() => {
|
||||
console.log(`Success! We're connected to OBS!`);
|
||||
this.websocket.getCurrentScene().then(res => this.currentScene = res.name);
|
||||
this.websocket.onSwitchScenes(data => this.currentScene = data['scene-name']);
|
||||
this.websocket.onSwitchScenes(data => {
|
||||
console.log(`New Active Scene: ${data.sceneName}`);
|
||||
this.currentScene = data.sceneName;
|
||||
});
|
||||
resolve();
|
||||
})
|
||||
.catch(reject);
|
||||
@@ -28,19 +31,28 @@ function GHOBS(config) {
|
||||
// Shows a video in the given scene/item and then hides it and switches back to the original scene when finished
|
||||
this.playVideoInScene = (video, scene, callback) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let originalScene = this.currentScene;
|
||||
let originalScene = this.currentScene || false;
|
||||
console.log(`Changing scene from ${originalScene} to ${scene}`);
|
||||
this.websocket.setCurrentScene({"scene-name": scene})
|
||||
.then(res => {
|
||||
// set the file path on the source
|
||||
console.log(`Setting file path to: ${video.filePath}`);
|
||||
this.websocket.setSourceSettings({"sourceName": video.sceneItem, "sourceSettings": {"local_file": video.filePath}})
|
||||
// show the video scene item
|
||||
.then(data => this.websocket.setSceneItemProperties({"item": video.sceneItem, "scene-name": scene, "visible": true}))
|
||||
.then(data => {console.log(`Showing ${video.sceneItem}`); this.websocket.setSceneItemProperties({"item": video.sceneItem, "scene-name": scene, "visible": true})})
|
||||
// when the video is over, hide it and trigger the user callback, but resolve promise immediately with the timer
|
||||
.then(data => {
|
||||
resolve(setTimeout(() => {
|
||||
console.log(`Hiding ${video.sceneItem}`);
|
||||
this.websocket.setSceneItemProperties({"item": video.sceneItem, "scene-name": scene, "visible": false});
|
||||
if (originalScene) {
|
||||
console.log(`Switching scene back to ${originalScene}`);
|
||||
this.websocket.setCurrentScene({"scene-name": originalScene});
|
||||
}
|
||||
if (typeof callback !== 'undefined') {
|
||||
console.log('Triggering user callback');
|
||||
callback(data);
|
||||
}
|
||||
}, video.length*1000))
|
||||
});
|
||||
})
|
||||
@@ -65,6 +77,33 @@ function GHOBS(config) {
|
||||
this.hideActivity = () => {
|
||||
return this.websocket.setSceneItemProperties({"item": this.config.currentActivitySceneItemName, "scene-name": this.config.defaultSceneName, "visible": false});
|
||||
};
|
||||
|
||||
this.showRoomGrind = (playTime, callback) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.websocket.setSceneItemProperties({"item": "room-grind", "scene-name": this.config.defaultSceneName, "visible": true})
|
||||
.then(res => {
|
||||
this.showActivity("NOW SHOWING: TTAS Room Grind !ttas");
|
||||
resolve(setTimeout(() => {
|
||||
// after timeout, hide room-grind and call user callback
|
||||
this.websocket.setSceneItemProperties({"item": "room-grind", "scene-name": this.config.defaultSceneName, "visible": false});
|
||||
if (typeof callback !== 'undefined') callback();
|
||||
}, playTime*1000));
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
|
||||
this.setVisible = (item, scene, visible) => {
|
||||
return this.websocket.setSceneItemProperties({"item": item, "scene-name": scene, "visible": visible});
|
||||
};
|
||||
|
||||
this.show = (item, scene) => {
|
||||
return this.setVisible(item, scene, true);
|
||||
};
|
||||
|
||||
this.hide = (item, scene) => {
|
||||
return this.setVisible(item, scene, false);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = GHOBS;
|
||||
|
||||
Reference in New Issue
Block a user