Giter Site home page Giter Site logo

oddworks-ooyala-provider's Introduction

Oddworks Ooyala Provider

An Ooyala provider plugin for the Oddworks content server.

Installation

Install the npm package as a Node.js library:

npm install --save oddworks-ooyala-provider

For full Ooyala Backlot API documentation see support.ooyala.com/developers/documentation/concepts/chapter_api_setup.html.

Oddworks Server Integration

The Oddworks-Ooyala provider is designed to be integrated with an Oddworks server catalog, specifically as a provider. To initialize the plugin in your server:

const ooyalaProvider = require('oddworks-ooyala-provider');

// See https://github.com/oddnetworks/oddworks/tree/master/lib/services/catalog#patterns
// for more information regarding an Oddcast Bus.
const bus = createMyOddcastBus();

const options = {
    bus: bus,
    apiKey: process.env.OOYALA_API_KEY,
    secretKey: process.env.OOYALA_SECRET_KEY
};

ooyalaProvider.initialize(options).then(provider => {
    console.log('Initialized provider "%s"', provider.name);
}).catch(err => {
    console.error(err.stack || err.message || err);
});

The initialization process will attach Oddcast listeners for the following queries:

  • bus.query({role: 'provider', cmd: 'get', source: 'ooyala-label-provider'})
  • bus.query({role: 'provider', cmd: 'get', source: 'ooyala-asset-provider'})

To use them you send Oddcast commands to save a specification object:

// To create a collection based on a Backlot label:
bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, {
    channel: 'abc',
    type: 'collectionSpec',
    source: 'ooyala-label-provider',
    label: {id: '123456'}
});

// To create a video based on a Backlot asset:
bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, {
    channel: 'abc',
    type: 'videoSpec',
    source: 'ooyala-asset-provider',
    asset: {external_id: '123456'}
});

Transform Functions

This library provides a default transform function for collections and assets. Usually you don't want to use the default. You'll want to provide your own like this:

const ooyalaProvider = require('oddworks-ooyala-provider');
const bus = createMyOddcastBus();

const options = {
    bus: bus,
    collectionTransform: myCollectionTransform,
    assetTransform: myAssetTransform
};

ooyalaProvider.initialize(options).then(provider => {
    console.log('Initialized provider "%s"', provider.name);
}).catch(err => {
    console.error(err.stack || err.message || err);
});

Your transform functions myCollectionTransform and myAssetTransform will be called when the ooyala-label-provider and ooyala-asset-provider have respectively received a response from the Backlot API. Each transform will be called with 2 arguments: The spec object and the Backlot API response object.

See lib/default-asset-transform and lib/default-collection-transform for more info.

Ooyala API Client

You can create a stand-alone API client outside of the Oddworks provider:

const ooyalaProvider = require('oddworks-ooyala-provider');

const client = ooyalaProvider.createClient({
    bus: bus,
    apiKey: process.env.OOYALA_API_KEY,
    secretKey: process.env.OOYALA_SECRET_KEY
});

The client can also be initialized with the high performance GET API using the baseUrl option (see below).

Client Methods

All methods return a Promise.

  • client.getLabels()
  • client.getLabel({labelId})
  • client.getChildLabels({labelId})
  • client.getAssetsByLabel({labelId})
  • client.getAsset({assetId})
  • client.getAssetMetadata({assetId})
  • client.getAssetStreams({assetId})

Command Line Interface

You can interact with the Backlot client using the CLI tool. To get started, run:

bin/backlot --help

To authenticate the API you'll need to export the following environment variables:

  • BACKLOT_API_KEY The Backlot API key
  • BACKLOT_SECRET_KEY The Backlot secret key

To get help with commands:

bin/backlot list --help
bin/backlot req --help

High Performance API

Ooyala offers a CDN API for serving GET requests only, which may be preferable to the standard Backlot API. To use it, initialize the provider like this:

const ooyalaProvider = require('oddworks-ooyala-provider');

const options = {
    bus: bus,
    apiKey: process.env.OOYALA_API_KEY,
    secretKey: process.env.OOYALA_SECRET_KEY,
    // Use the high performance API
    baseUrl: 'https://cdn-api.ooyala.com'
};

ooyalaProvider.initialize(options).then(provider => {
    console.log('Initialized provider "%s"', provider.name);
}).catch(err => {
    console.error(err.stack || err.message || err);
});

License

Apache 2.0 © Odd Networks

oddworks-ooyala-provider's People

Contributors

kixxauth avatar aljachimiak avatar blainsmith avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.