Skip to content

Commit

Permalink
Setup project and add status example
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffski committed Jul 27, 2019
0 parents commit 93c89a1
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Shotstack Node Examples
38 changes: 38 additions & 0 deletions examples/status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const Shotstack = require('shotstack-sdk');

const defaultClient = Shotstack.ApiClient.instance;
const DeveloperKey = defaultClient.authentications['DeveloperKey'];
const api = new Shotstack.DefaultApi()
const id = process.argv[2];

let apiUrl = 'https://api.shotstack.io/stage';

if (!process.env.SHOTSTACK_KEY) {
console.log('API Key is required. Set using: export SHOTSTACK_KEY=your_key_here');
process.exit(1);
}

if (process.env.SHOTSTACK_HOST) {
apiUrl = process.env.SHOTSTACK_HOST;
}

defaultClient.basePath = apiUrl;
DeveloperKey.apiKey = process.env.SHOTSTACK_KEY;

api.getRender(id).then((data) => {
let status = data.response.status;
let url = data.response.url;

console.log('Status: ' + status.toUpperCase() + '\n');

if (status == 'done') {
console.log('>> Video URL: ' + url);
} else if (status == 'failed') {
console.log('>> Something went wrong, rendering has terminated and will not continue.');
} else {
console.log('>> Rendering in progress, please try again shortly.\n>> Note: Rendering may take up to 1 minute to complete.');
}
}, (error) => {
console.error('Request failed or not found: ', error);
process.exit(1);
});
Empty file added examples/text.js
Empty file.
174 changes: 174 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "shotstack-node-examples",
"version": "1.0.0",
"description": "Node JS Examples using the Shotstack cloud video editing API",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jeff Shillitto",
"license": "MIT",
"dependencies": {
"shotstack-sdk": "0.0.3"
}
}

0 comments on commit 93c89a1

Please sign in to comment.