Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 = (layer % 2 === 0) ? 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);
Add Comment
Please, Sign In to add comment