Last active
December 10, 2018 09:03
-
-
Save toontoet/359755c639b933f4f7a11e29b2c26d3e to your computer and use it in GitHub Desktop.
CasparCG Hammer script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {CasparCG} = require("casparcg-connection"); | |
const {CasparCGSocketStatusEvent} = require("casparcg-connection"); | |
let host = process.argv[2] || 'localhost'; | |
let port = process.argv[3] || '5250'; | |
let check = process.argv[4] || 'info'; | |
let file = process.argv[5] || null; | |
let connection = new CasparCG({host: host, port: port, autoConnect: false}); | |
let checks = { | |
threads: async () => { | |
try { | |
let command = await connection.infoThreads(); | |
if (command.response.data.length) { | |
console.log(command.response.data.length); | |
} | |
} catch (e) { | |
console.log('FAIL'); | |
} finally { | |
connection.disconnect(); | |
clearTimeout(limit); | |
} | |
}, | |
info: async () => { | |
//console.log('in info check'); | |
try { | |
let command = await connection.info(1,1); | |
if (command.response && command.response.raw === '201 INFO OK') { | |
console.log(command.response); | |
} | |
else { | |
console.log('FAIL'); | |
} | |
} catch (e) { | |
// Deal with the fact the chain failed | |
console.log('FAIL') | |
} finally { | |
setTimeout(checks['info'], 20) | |
} | |
}, | |
load: async (layer) => { | |
console.log('in load'); | |
try { | |
if (layer >= 5) layer = 1; | |
let clip = file ; | |
let command = await connection.loadbg(1, layer, clip); | |
if (command.response) { | |
console.log(command.response); | |
} | |
else { | |
console.log('FAIL'); | |
} | |
} catch (e) { | |
// Deal with the fact the chain failed | |
console.log('FAIL') | |
} finally { | |
layer++; | |
setTimeout(checks['load'], 100, layer) | |
} | |
} | |
}; | |
connection.connect(); | |
( | |
checks[check] | |
)(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment