npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dolbyio/dolbyio-rest-apis-client

v5.0.2

Published

Node.JS wrapper for the Dolby.io REST APIs

Downloads

1,412

Readme

Build Package Build Documentation Publish Package npm License GitHub Documentation

Dolby.io REST APIs Client for Node.JS is wrapper for the Dolby Millicast and Dolby.io Media REST APIs.

Install this project

Run the npm command to install the package @dolbyio/dolbyio-rest-apis-client into your Node project:

npm install @dolbyio/dolbyio-rest-apis-client

Dolby Millicast Examples

Create a publish token

import { streaming } from '@dolbyio/dolbyio-rest-apis-client';

const API_KEY = process.env.DOLBYIO_API_SECRET;

const publishToken = await streaming.publishToken.create(API_KEY, {
    label: 'My token',
    streams: [
        {
            streamName: 'feedA',
        },
    ],
});
console.log(publishToken);

Create a subscribe token

import { streaming } from '@dolbyio/dolbyio-rest-apis-client';

const API_KEY = process.env.DOLBYIO_API_SECRET;

const subscribeToken = await streaming.subscribeToken.create(API_KEY, {
    label: 'My token',
    streams: [
        {
            streamName: 'feedA',
        },
    ],
});
console.log(subscribeToken);

Media Examples

Here is an example on how to upload a file to the Dolby.io temporary cloud storage, enhance that file and download the result.

Get an API token

Get the App Key and Secret from the Dolby.io dashboard and use the following code in your python script.

import { media } from '@dolbyio/dolbyio-rest-apis-client';

const APP_KEY = process.env.DOLBYIO_APP_KEY;
const APP_SECRET = process.env.DOLBYIO_APP_SECRET;

// Request an Access Token
const jwt = await media.authentication.getApiAccessToken(APP_KEY, APP_SECRET);
console.log('Access token', jwt);

Upload a file for processing

Upload a media file to the Dolby.io temporary cloud storage for processing:

// Temporary storage URL that will be used as reference for the job processing
const inputUrl = 'dlb://in/file.mp4';
// Local path of the file to upload
const originalFilePath = '/path/to/original_file.mp4';

await media.io.uploadFile(jwt, inputUrl, originalFilePath);

Start an enhance job

Generate a job description and send it to Dolby.io.

// Temporary storage URL that will be used as reference for the job processing
const outputUrl = 'dlb://out/file.mp4';

const jobDescription = JSON.stringify({
    content: { type: 'podcast' },
    input: inputUrl,
    output: outputUrl,
});

const jobId = await media.enhance.start(jwt, jobDescription);
console.log(`Job ID: ${jobId}`);

Wait for the job to complete

Get the job status and wait until it is completed.

const sleep = (delay) => new Promise((r) => setTimeout(r, delay));

let result = await media.enhance.getResults(jwt, jobId);
while (result.status === 'Pending' || result.status === 'Running') {
    console.log(`Job status is ${result.status}, taking a 5 second break...`);
    await sleep(5000);

    result = await media.enhance.getResults(jwt, jobId);
}

if (result.status !== 'Success') {
    console.error('There was a problem with processing the file', result);
    return;
}

Download a processed file

At this stage, the file has been processed and written to the temporary storage so we can download it.

// Local path where to download the file to
const enhancedFilePath = '/path/to/enhanced_file.mp4';

await media.io.downloadFile(jwt, outputUrl, enhancedFilePath);

Logs

You can also print the logs in the console and select the log level by using the following code.

import { Logger } from '@dolbyio/dolbyio-rest-apis-client';

Logger.useDefaults({
    defaultLevel: Logger.TRACE,
});

How to

To build the dist folder, run the command:

npm run build

The documentation is built on TypeDoc, to generate the doc, run the following command. You will find the HTML files in the docs folder.

npm run docs

Related Projects