@dolbyio/dolbyio-rest-apis-client 3.5.1 → 3.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -5
- package/dist/index.js +1 -1
- package/dist/internal/httpHelpers.d.ts +7 -0
- package/dist/internal/httpHelpers.js +38 -2
- package/dist/media/analyze.d.ts +1 -1
- package/dist/media/analyze.js +1 -1
- package/dist/media/analyzeMusic.d.ts +37 -0
- package/dist/media/analyzeMusic.js +89 -0
- package/dist/media/analyzeSpeech.d.ts +1 -1
- package/dist/media/analyzeSpeech.js +1 -1
- package/dist/media/index.d.ts +2 -1
- package/dist/media/index.js +3 -1
- package/dist/media/io.d.ts +12 -0
- package/dist/media/io.js +48 -12
- package/dist/media/types/analyzeMusic.d.ts +6 -0
- package/dist/media/types/analyzeMusic.js +5 -0
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -116,9 +116,11 @@ console.log(subscribeToken);
|
|
|
116
116
|
|
|
117
117
|
## Media Examples
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
Here is an example on how to upload a file to the Dolby.io temporary cloud storage, enhance that file and download the result.
|
|
120
|
+
|
|
121
|
+
### Get an API token
|
|
120
122
|
|
|
121
|
-
|
|
123
|
+
Get the App Key and Secret from the Dolby.io dashboard and use the following code in your python script.
|
|
122
124
|
|
|
123
125
|
```javascript
|
|
124
126
|
const dolbyio = require('@dolbyio/dolbyio-rest-apis-client');
|
|
@@ -128,18 +130,72 @@ const APP_SECRET = 'YOUR_APP_SECRET';
|
|
|
128
130
|
|
|
129
131
|
// Request an Access Token
|
|
130
132
|
const jwt = await dolbyio.authentication.getApiAccessToken(APP_KEY, APP_SECRET);
|
|
133
|
+
console.log('Access token', jwt);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Upload a file for processing
|
|
137
|
+
|
|
138
|
+
Upload a media file to the Dolby.io temporary cloud storage for processing:
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
// Temporary storage URL that will be used as reference for the job processing
|
|
142
|
+
const inputUrl = 'dlb://in/file.mp4';
|
|
143
|
+
// Local path of the file to upload
|
|
144
|
+
const originalFilePath = '/path/to/original_file.mp4';
|
|
145
|
+
|
|
146
|
+
await dolbyio.io.uploadFile(jwt, inputUrl, originalFilePath);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Start an enhance job
|
|
150
|
+
|
|
151
|
+
Generate a job description and send it to Dolby.io.
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
// Temporary storage URL that will be used as reference for the job processing
|
|
155
|
+
const outputUrl = 'dlb://out/file.mp4';
|
|
131
156
|
|
|
132
157
|
const jobDescription = JSON.stringify({
|
|
133
158
|
content: { type: 'podcast' },
|
|
134
|
-
input:
|
|
135
|
-
output:
|
|
159
|
+
input: inputUrl,
|
|
160
|
+
output: outputUrl,
|
|
136
161
|
});
|
|
137
162
|
|
|
138
163
|
const jobId = await dolbyio.media.enhance.start(jwt, jobDescription);
|
|
139
|
-
|
|
140
164
|
console.log(`Job ID: ${jobId}`);
|
|
141
165
|
```
|
|
142
166
|
|
|
167
|
+
### Wait for the job to complete
|
|
168
|
+
|
|
169
|
+
Get the job status and wait until it is completed.
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
const sleep = (delay) => new Promise((r) => setTimeout(r, delay));
|
|
173
|
+
|
|
174
|
+
let result = await dolbyio.media.enhance.getResults(jwt, jobId);
|
|
175
|
+
while (result.status === 'Pending' || result.status === 'Running') {
|
|
176
|
+
console.log(`Job status is ${result.status}, taking a 5 second break...`);
|
|
177
|
+
await sleep(5000);
|
|
178
|
+
|
|
179
|
+
result = await dolbyio.media.enhance.getResults(jwt, jobId);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (result.status !== 'Success') {
|
|
183
|
+
console.error('There was a problem with processing the file', result);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Download a processed file
|
|
189
|
+
|
|
190
|
+
At this stage, the file has been processed and written to the temporary storage so we can download it.
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
// Local path where to download the file to
|
|
194
|
+
const enhancedFilePath = '/path/to/enhanced_file.mp4';
|
|
195
|
+
|
|
196
|
+
await dolbyio.io.downloadFile(jwt, outputUrl, enhancedFilePath);
|
|
197
|
+
```
|
|
198
|
+
|
|
143
199
|
## Build this project
|
|
144
200
|
|
|
145
201
|
To build the `dist` folder, run the command:
|
package/dist/index.js
CHANGED
|
@@ -15,5 +15,5 @@ var streaming = _interopRequireWildcard(require("./streaming"));
|
|
|
15
15
|
exports.streaming = streaming;
|
|
16
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
|
-
var version = "3.5.
|
|
18
|
+
var version = "3.5.3";
|
|
19
19
|
exports.version = version;
|
|
@@ -55,3 +55,10 @@ export declare const sendPatch: (options: RequestOptions) => Promise<any>;
|
|
|
55
55
|
* @param options Request options.
|
|
56
56
|
*/
|
|
57
57
|
export declare const download: (filepath: string, options: RequestOptions) => Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Upload a file.
|
|
60
|
+
*
|
|
61
|
+
* @param filepath The local path of the file to upload.
|
|
62
|
+
* @param uploadUrl Where to upload the file to.
|
|
63
|
+
*/
|
|
64
|
+
export declare const upload: (filepath: string, uploadUrl: string) => Promise<void>;
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.sendPut = exports.sendPost = exports.sendPatch = exports.sendGet = exports.sendDelete = exports.download = void 0;
|
|
6
|
+
exports.upload = exports.sendPut = exports.sendPost = exports.sendPatch = exports.sendGet = exports.sendDelete = exports.download = void 0;
|
|
7
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
8
|
var _followRedirects = require("follow-redirects");
|
|
9
|
+
var _https = _interopRequireDefault(require("https"));
|
|
9
10
|
var _url = require("url");
|
|
10
11
|
var _index = require("../index");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -250,4 +251,39 @@ var download = function download(filepath, options) {
|
|
|
250
251
|
req.end();
|
|
251
252
|
});
|
|
252
253
|
};
|
|
253
|
-
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Upload a file.
|
|
257
|
+
*
|
|
258
|
+
* @param filepath The local path of the file to upload.
|
|
259
|
+
* @param uploadUrl Where to upload the file to.
|
|
260
|
+
*/
|
|
261
|
+
exports.download = download;
|
|
262
|
+
var upload = function upload(filepath, uploadUrl) {
|
|
263
|
+
// Get the size of the file to upload
|
|
264
|
+
var fileSize = _fs["default"].statSync(filepath).size;
|
|
265
|
+
return new Promise(function (resolve, reject) {
|
|
266
|
+
var opts = {
|
|
267
|
+
method: 'PUT',
|
|
268
|
+
headers: {
|
|
269
|
+
"Content-Length": fileSize
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
var req = _https["default"].request(uploadUrl, opts, function (res) {
|
|
273
|
+
console.log("[".concat(opts.method, "] ").concat(res.statusCode, " - ").concat(uploadUrl));
|
|
274
|
+
if (res.statusCode < 200 || res.statusCode >= 400) {
|
|
275
|
+
reject('This request has been rejected with the response code ' + res.statusCode);
|
|
276
|
+
} else {
|
|
277
|
+
resolve();
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
req.on('error', function (error) {
|
|
281
|
+
console.error(error);
|
|
282
|
+
reject(error);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Start the upload of the file
|
|
286
|
+
_fs["default"].createReadStream(filepath).pipe(req);
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
exports.upload = upload;
|
package/dist/media/analyze.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare const start: (accessToken: JwtToken, jobContent: string) => Promi
|
|
|
31
31
|
*
|
|
32
32
|
* For a given job_id, this method will check the job status.
|
|
33
33
|
*
|
|
34
|
-
* When `
|
|
34
|
+
* When {@link AnalyzeJob.status} is `Success`, you'll be able to retrieve your result from the `output` location you provided in the original {@link start} request.
|
|
35
35
|
*
|
|
36
36
|
* @link https://docs.dolby.io/media-apis/reference/media-analyze-get
|
|
37
37
|
*
|
package/dist/media/analyze.js
CHANGED
|
@@ -61,7 +61,7 @@ var start = /*#__PURE__*/function () {
|
|
|
61
61
|
*
|
|
62
62
|
* For a given job_id, this method will check the job status.
|
|
63
63
|
*
|
|
64
|
-
* When `
|
|
64
|
+
* When {@link AnalyzeJob.status} is `Success`, you'll be able to retrieve your result from the `output` location you provided in the original {@link start} request.
|
|
65
65
|
*
|
|
66
66
|
* @link https://docs.dolby.io/media-apis/reference/media-analyze-get
|
|
67
67
|
*
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import JwtToken from '../types/jwtToken';
|
|
2
|
+
import { AnalyzeMusicJob } from './types/analyzeMusic';
|
|
3
|
+
/**
|
|
4
|
+
* Start analyzing to learn about music in your media.
|
|
5
|
+
*
|
|
6
|
+
* The `input` location of your source media file and `output` location of your Analyze JSON results file are required.
|
|
7
|
+
*
|
|
8
|
+
* This is an asynchronous operation so you will receive a `job_id` to be used to get the job status and result.
|
|
9
|
+
*
|
|
10
|
+
* @link https://docs.dolby.io/media-apis/reference/media-analyze-music-post
|
|
11
|
+
*
|
|
12
|
+
* Beta API
|
|
13
|
+
* This API is being made available as an early preview.
|
|
14
|
+
* If you have feedback on how you'd like to use the API please reach out to share your feedback with our team.
|
|
15
|
+
* https://dolby.io/contact
|
|
16
|
+
*
|
|
17
|
+
* @param accessToken Access token to use for authentication.
|
|
18
|
+
* @param jobContent Content of the job description as a JSON payload. You can find the definition at this URL: https://docs.dolby.io/media-apis/reference/media-analyze-music-post
|
|
19
|
+
*
|
|
20
|
+
* @returns The job identifier through a {@link Promise}.
|
|
21
|
+
*/
|
|
22
|
+
export declare const start: (accessToken: JwtToken, jobContent: string) => Promise<string | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Gets Music Analytics Status.
|
|
25
|
+
*
|
|
26
|
+
* For a given {@link jobId}, this method will check if the processing task has completed.
|
|
27
|
+
*
|
|
28
|
+
* When {@link AnalyzeMusicJob.status} is `Success`, you'll be able to retrieve your result from the `output` location you provided in the original {@link start} request.
|
|
29
|
+
*
|
|
30
|
+
* @link https://docs.dolby.io/media-apis/reference/media-analyze-music-get
|
|
31
|
+
*
|
|
32
|
+
* @param accessToken Access token to use for authentication.
|
|
33
|
+
* @param jobId Identifier of the job to retrieve.
|
|
34
|
+
*
|
|
35
|
+
* @returns The {@link AnalyzeMusicJob} object through a {@link Promise}.
|
|
36
|
+
*/
|
|
37
|
+
export declare const getResults: (accessToken: JwtToken, jobId: string) => Promise<AnalyzeMusicJob>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.start = exports.getResults = void 0;
|
|
8
|
+
var _jobsHelpers = require("./internal/jobsHelpers");
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
|
+
/**
|
|
13
|
+
* Start analyzing to learn about music in your media.
|
|
14
|
+
*
|
|
15
|
+
* The `input` location of your source media file and `output` location of your Analyze JSON results file are required.
|
|
16
|
+
*
|
|
17
|
+
* This is an asynchronous operation so you will receive a `job_id` to be used to get the job status and result.
|
|
18
|
+
*
|
|
19
|
+
* @link https://docs.dolby.io/media-apis/reference/media-analyze-music-post
|
|
20
|
+
*
|
|
21
|
+
* Beta API
|
|
22
|
+
* This API is being made available as an early preview.
|
|
23
|
+
* If you have feedback on how you'd like to use the API please reach out to share your feedback with our team.
|
|
24
|
+
* https://dolby.io/contact
|
|
25
|
+
*
|
|
26
|
+
* @param accessToken Access token to use for authentication.
|
|
27
|
+
* @param jobContent Content of the job description as a JSON payload. You can find the definition at this URL: https://docs.dolby.io/media-apis/reference/media-analyze-music-post
|
|
28
|
+
*
|
|
29
|
+
* @returns The job identifier through a {@link Promise}.
|
|
30
|
+
*/
|
|
31
|
+
var start = /*#__PURE__*/function () {
|
|
32
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessToken, jobContent) {
|
|
33
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
34
|
+
while (1) {
|
|
35
|
+
switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
_context.next = 2;
|
|
38
|
+
return (0, _jobsHelpers.startJob)(accessToken, '/media/analyze/music', jobContent);
|
|
39
|
+
case 2:
|
|
40
|
+
return _context.abrupt("return", _context.sent);
|
|
41
|
+
case 3:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, _callee);
|
|
47
|
+
}));
|
|
48
|
+
return function start(_x, _x2) {
|
|
49
|
+
return _ref.apply(this, arguments);
|
|
50
|
+
};
|
|
51
|
+
}();
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets Music Analytics Status.
|
|
55
|
+
*
|
|
56
|
+
* For a given {@link jobId}, this method will check if the processing task has completed.
|
|
57
|
+
*
|
|
58
|
+
* When {@link AnalyzeMusicJob.status} is `Success`, you'll be able to retrieve your result from the `output` location you provided in the original {@link start} request.
|
|
59
|
+
*
|
|
60
|
+
* @link https://docs.dolby.io/media-apis/reference/media-analyze-music-get
|
|
61
|
+
*
|
|
62
|
+
* @param accessToken Access token to use for authentication.
|
|
63
|
+
* @param jobId Identifier of the job to retrieve.
|
|
64
|
+
*
|
|
65
|
+
* @returns The {@link AnalyzeMusicJob} object through a {@link Promise}.
|
|
66
|
+
*/
|
|
67
|
+
exports.start = start;
|
|
68
|
+
var getResults = /*#__PURE__*/function () {
|
|
69
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(accessToken, jobId) {
|
|
70
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
71
|
+
while (1) {
|
|
72
|
+
switch (_context2.prev = _context2.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
_context2.next = 2;
|
|
75
|
+
return (0, _jobsHelpers.getJobResults)(accessToken, '/media/analyze/music', jobId);
|
|
76
|
+
case 2:
|
|
77
|
+
return _context2.abrupt("return", _context2.sent);
|
|
78
|
+
case 3:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context2.stop();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, _callee2);
|
|
84
|
+
}));
|
|
85
|
+
return function getResults(_x3, _x4) {
|
|
86
|
+
return _ref2.apply(this, arguments);
|
|
87
|
+
};
|
|
88
|
+
}();
|
|
89
|
+
exports.getResults = getResults;
|
|
@@ -25,7 +25,7 @@ export declare const start: (accessToken: JwtToken, jobContent: string) => Promi
|
|
|
25
25
|
*
|
|
26
26
|
* For a given {@link jobId}, this method will check if the processing task has completed.
|
|
27
27
|
*
|
|
28
|
-
* When {@link AnalyzeSpeechJob.status} is `Success`, you'll be able to retrieve your result from the `output` location you provided in the original
|
|
28
|
+
* When {@link AnalyzeSpeechJob.status} is `Success`, you'll be able to retrieve your result from the `output` location you provided in the original {@link start} request.
|
|
29
29
|
*
|
|
30
30
|
* @link https://docs.dolby.io/media-apis/reference/media-analyze-speech-get
|
|
31
31
|
*
|
|
@@ -55,7 +55,7 @@ var start = /*#__PURE__*/function () {
|
|
|
55
55
|
*
|
|
56
56
|
* For a given {@link jobId}, this method will check if the processing task has completed.
|
|
57
57
|
*
|
|
58
|
-
* When {@link AnalyzeSpeechJob.status} is `Success`, you'll be able to retrieve your result from the `output` location you provided in the original
|
|
58
|
+
* When {@link AnalyzeSpeechJob.status} is `Success`, you'll be able to retrieve your result from the `output` location you provided in the original {@link start} request.
|
|
59
59
|
*
|
|
60
60
|
* @link https://docs.dolby.io/media-apis/reference/media-analyze-speech-get
|
|
61
61
|
*
|
package/dist/media/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as analyze from './analyze';
|
|
2
2
|
import * as analyzeSpeech from './analyzeSpeech';
|
|
3
|
+
import * as analyzeMusic from './analyzeMusic';
|
|
3
4
|
import * as diagnose from './diagnose';
|
|
4
5
|
import * as enhance from './enhance';
|
|
5
6
|
import * as io from './io';
|
|
@@ -7,4 +8,4 @@ import * as jobs from './jobs';
|
|
|
7
8
|
import * as mastering from './mastering';
|
|
8
9
|
import * as transcode from './transcode';
|
|
9
10
|
import * as webhooks from './webhooks';
|
|
10
|
-
export { analyze, analyzeSpeech, diagnose, enhance, io, jobs, mastering, transcode, webhooks };
|
|
11
|
+
export { analyze, analyzeSpeech, analyzeMusic, diagnose, enhance, io, jobs, mastering, transcode, webhooks };
|
package/dist/media/index.js
CHANGED
|
@@ -4,11 +4,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.webhooks = exports.transcode = exports.mastering = exports.jobs = exports.io = exports.enhance = exports.diagnose = exports.analyzeSpeech = exports.analyze = void 0;
|
|
7
|
+
exports.webhooks = exports.transcode = exports.mastering = exports.jobs = exports.io = exports.enhance = exports.diagnose = exports.analyzeSpeech = exports.analyzeMusic = exports.analyze = void 0;
|
|
8
8
|
var analyze = _interopRequireWildcard(require("./analyze"));
|
|
9
9
|
exports.analyze = analyze;
|
|
10
10
|
var analyzeSpeech = _interopRequireWildcard(require("./analyzeSpeech"));
|
|
11
11
|
exports.analyzeSpeech = analyzeSpeech;
|
|
12
|
+
var analyzeMusic = _interopRequireWildcard(require("./analyzeMusic"));
|
|
13
|
+
exports.analyzeMusic = analyzeMusic;
|
|
12
14
|
var diagnose = _interopRequireWildcard(require("./diagnose"));
|
|
13
15
|
exports.diagnose = diagnose;
|
|
14
16
|
var enhance = _interopRequireWildcard(require("./enhance"));
|
package/dist/media/io.d.ts
CHANGED
|
@@ -31,6 +31,18 @@ export declare const getUploadUrl: (accessToken: JwtToken, dlbUrl: string) => Pr
|
|
|
31
31
|
* @returns The download URL through a {@link Promise}.
|
|
32
32
|
*/
|
|
33
33
|
export declare const getDownloadUrl: (accessToken: JwtToken, dlbUrl: string) => Promise<string | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Upload a media file to the Dolby.io temporary storage.
|
|
36
|
+
*
|
|
37
|
+
* The temporary storage should allow you to read and write to the dlb:// locations for a period of at least 24 hours before it is removed.
|
|
38
|
+
*
|
|
39
|
+
* @link https://docs.dolby.io/media-apis/reference/media-input-post
|
|
40
|
+
*
|
|
41
|
+
* @param accessToken Access token to use for authentication.
|
|
42
|
+
* @param dlbUrl The `url` should be in the form `dlb://object-key` where the object-key can be any alpha-numeric string. The object-key is unique to your account API Key so there is no risk of collision with other users.
|
|
43
|
+
* @param filePath Local path of the file you want to upload.
|
|
44
|
+
*/
|
|
45
|
+
export declare const uploadFile: (accessToken: JwtToken, dlbUrl: string, filePath: string) => Promise<void>;
|
|
34
46
|
/**
|
|
35
47
|
* Download a media file.
|
|
36
48
|
*
|
package/dist/media/io.js
CHANGED
|
@@ -4,7 +4,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getUploadUrl = exports.getDownloadUrl = exports.downloadFile = void 0;
|
|
7
|
+
exports.uploadFile = exports.getUploadUrl = exports.getDownloadUrl = exports.downloadFile = void 0;
|
|
8
8
|
var _httpHelpers = require("./internal/httpHelpers");
|
|
9
9
|
var _httpHelpers2 = require("../internal/httpHelpers");
|
|
10
10
|
var _urls = require("./internal/urls");
|
|
@@ -129,6 +129,42 @@ var getDownloadUrl = /*#__PURE__*/function () {
|
|
|
129
129
|
};
|
|
130
130
|
}();
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Upload a media file to the Dolby.io temporary storage.
|
|
134
|
+
*
|
|
135
|
+
* The temporary storage should allow you to read and write to the dlb:// locations for a period of at least 24 hours before it is removed.
|
|
136
|
+
*
|
|
137
|
+
* @link https://docs.dolby.io/media-apis/reference/media-input-post
|
|
138
|
+
*
|
|
139
|
+
* @param accessToken Access token to use for authentication.
|
|
140
|
+
* @param dlbUrl The `url` should be in the form `dlb://object-key` where the object-key can be any alpha-numeric string. The object-key is unique to your account API Key so there is no risk of collision with other users.
|
|
141
|
+
* @param filePath Local path of the file you want to upload.
|
|
142
|
+
*/
|
|
143
|
+
exports.getDownloadUrl = getDownloadUrl;
|
|
144
|
+
var uploadFile = /*#__PURE__*/function () {
|
|
145
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(accessToken, dlbUrl, filePath) {
|
|
146
|
+
var uploadUrl;
|
|
147
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
148
|
+
while (1) {
|
|
149
|
+
switch (_context4.prev = _context4.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
_context4.next = 2;
|
|
152
|
+
return getUploadUrl(accessToken, dlbUrl);
|
|
153
|
+
case 2:
|
|
154
|
+
uploadUrl = _context4.sent;
|
|
155
|
+
return _context4.abrupt("return", (0, _httpHelpers2.upload)(filePath, uploadUrl));
|
|
156
|
+
case 4:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context4.stop();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, _callee4);
|
|
162
|
+
}));
|
|
163
|
+
return function uploadFile(_x8, _x9, _x10) {
|
|
164
|
+
return _ref4.apply(this, arguments);
|
|
165
|
+
};
|
|
166
|
+
}();
|
|
167
|
+
|
|
132
168
|
/**
|
|
133
169
|
* Download a media file.
|
|
134
170
|
*
|
|
@@ -142,18 +178,18 @@ var getDownloadUrl = /*#__PURE__*/function () {
|
|
|
142
178
|
* @param dlbUrl The `url` should be in the form `dlb://object-key` where the object-key can be any alpha-numeric string. The object-key is unique to your account API Key so there is no risk of collision with other users.
|
|
143
179
|
* @param filePath Local file path where to download the file to.
|
|
144
180
|
*/
|
|
145
|
-
exports.
|
|
181
|
+
exports.uploadFile = uploadFile;
|
|
146
182
|
var downloadFile = /*#__PURE__*/function () {
|
|
147
|
-
var
|
|
183
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(accessToken, dlbUrl, filePath) {
|
|
148
184
|
var downloadUrl, idx, requestOptions;
|
|
149
|
-
return _regeneratorRuntime().wrap(function
|
|
185
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
150
186
|
while (1) {
|
|
151
|
-
switch (
|
|
187
|
+
switch (_context5.prev = _context5.next) {
|
|
152
188
|
case 0:
|
|
153
|
-
|
|
189
|
+
_context5.next = 2;
|
|
154
190
|
return getDownloadUrl(accessToken, dlbUrl);
|
|
155
191
|
case 2:
|
|
156
|
-
downloadUrl =
|
|
192
|
+
downloadUrl = _context5.sent;
|
|
157
193
|
downloadUrl = downloadUrl.replace('https://', '');
|
|
158
194
|
idx = downloadUrl.indexOf('/');
|
|
159
195
|
requestOptions = {
|
|
@@ -161,16 +197,16 @@ var downloadFile = /*#__PURE__*/function () {
|
|
|
161
197
|
path: downloadUrl.substring(idx + 1),
|
|
162
198
|
headers: {}
|
|
163
199
|
};
|
|
164
|
-
return
|
|
200
|
+
return _context5.abrupt("return", (0, _httpHelpers2.download)(filePath, requestOptions));
|
|
165
201
|
case 7:
|
|
166
202
|
case "end":
|
|
167
|
-
return
|
|
203
|
+
return _context5.stop();
|
|
168
204
|
}
|
|
169
205
|
}
|
|
170
|
-
},
|
|
206
|
+
}, _callee5);
|
|
171
207
|
}));
|
|
172
|
-
return function downloadFile(
|
|
173
|
-
return
|
|
208
|
+
return function downloadFile(_x11, _x12, _x13) {
|
|
209
|
+
return _ref5.apply(this, arguments);
|
|
174
210
|
};
|
|
175
211
|
}();
|
|
176
212
|
exports.downloadFile = downloadFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolbyio/dolbyio-rest-apis-client",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.3",
|
|
4
4
|
"description": "Node.JS wrapper for the dolby.io REST APIs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
},
|
|
14
14
|
"author": "Fabien Lavocat <fabien.lavocat@dolby.com>",
|
|
15
15
|
"license": "MIT",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"nodejs",
|
|
18
|
+
"api",
|
|
19
|
+
"sdk",
|
|
20
|
+
"rest",
|
|
21
|
+
"rest-api",
|
|
22
|
+
"webrtc",
|
|
23
|
+
"dolbyio"
|
|
24
|
+
],
|
|
16
25
|
"files": [
|
|
17
26
|
"dist/*",
|
|
18
27
|
"README.md"
|