-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeff Shillitto
committed
May 5, 2024
1 parent
eb29477
commit 3c17cdc
Showing
5 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const Shotstack = require('shotstack-sdk'); | ||
|
||
const defaultClient = Shotstack.ApiClient.instance; | ||
const DeveloperKey = defaultClient.authentications['DeveloperKey']; | ||
const api = new Shotstack.IngestApi(); | ||
|
||
const apiUrlBase = 'https://api.shotstack.io/ingest/'; | ||
let apiUrl = apiUrlBase + '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_CREATE_HOST) { | ||
apiUrl = process.env.SHOTSTACK_CREATE_HOST; | ||
} | ||
|
||
if (process.env.SHOTSTACK_ENV) { | ||
apiUrl = apiUrlBase + process.env.SHOTSTACK_ENV; | ||
} | ||
|
||
defaultClient.basePath = apiUrl; | ||
DeveloperKey.apiKey = process.env.SHOTSTACK_KEY; | ||
|
||
const size = new Shotstack.Size; | ||
size | ||
.setHeight(720); | ||
|
||
const rendition = new Shotstack.Rendition; | ||
rendition | ||
.setSize(size); | ||
|
||
const outputs = new Shotstack.Outputs; | ||
outputs | ||
.setRenditions([rendition]); | ||
|
||
const source = new Shotstack.Source; | ||
source | ||
.setUrl('https://shotstack-assets.s3.ap-southeast-2.amazonaws.com/footage/cliffs-sunset.mp4') | ||
.setOutputs(outputs); | ||
|
||
api.postSource(source).then((source) => { | ||
const id = source.data.id | ||
|
||
console.log(`Request 'queued' with id: ${id}\n`); | ||
console.log('>> Now check the progress by running:'); | ||
console.log(`>> node examples/ingest-api/status.js ${id}`); | ||
}, (error) => { | ||
console.error('Request failed: ', error); | ||
process.exit(1); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const Shotstack = require('shotstack-sdk'); | ||
|
||
const defaultClient = Shotstack.ApiClient.instance; | ||
const DeveloperKey = defaultClient.authentications['DeveloperKey']; | ||
const api = new Shotstack.IngestApi(); | ||
|
||
const apiUrlBase = 'https://api.shotstack.io/ingest/'; | ||
let apiUrl = apiUrlBase + 'stage'; | ||
|
||
const id = process.argv[2]; | ||
|
||
if (!id) { | ||
console.log(">> Please provide the UUID of the ingest task (i.e. node examples/ingest-api/status.js zzy7wxvy-1h1e-vt4j-kn0y-3qn7kj1hocpw)\n"); | ||
process.exit(1); | ||
} | ||
|
||
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; | ||
} | ||
|
||
if (process.env.SHOTSTACK_ENV) { | ||
apiUrl = apiUrlBase + process.env.SHOTSTACK_ENV; | ||
} | ||
|
||
defaultClient.basePath = apiUrl; | ||
DeveloperKey.apiKey = process.env.SHOTSTACK_KEY; | ||
|
||
api.getSource(id).then((source) => { | ||
const status = source.data.attributes.outputs.renditions[0].status; | ||
|
||
console.log(`Status: '${status}'\n`); | ||
|
||
if (status == 'ready') { | ||
console.log(`>> Source URL: ${source.data.attributes.source}`); | ||
console.log(`>> Rendition URL: ${source.data.attributes.outputs.renditions[0].url}`); | ||
} else if (status == 'failed') { | ||
console.log('>> Something went wrong, processing has terminated and will not continue.'); | ||
} else { | ||
console.log('>> Processing in progress, please try again shortly.\n>> Note: Processing may take some time to complete.'); | ||
} | ||
}, (error) => { | ||
console.error('Request failed or not found: ', error); | ||
process.exit(1); | ||
}); |