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

oddworks-brightcove-provider

v1.4.3

Published

An Oddworks provider plugin for Brightcove APIs

Downloads

23

Readme

Oddworks Brightcove Provider

A Brightcove provider plugin for the Oddworks content server.

pipeline status

Installation

Install the npm package as a Node.js library:

npm install --save oddworks-brightcove-provider

For full Brightcove API documentation see docs.brightcove.com/en/video-cloud/concepts/api-overview/api-overview.html.

Oddworks Server Integration

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

const brightcoveProvider = require('oddworks-brightcove-provider');

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

const options = {
    bus: bus,
    clientId: process.env.BRIGHTCOVE_CLIENT_ID,
    clientSecret: process.env.BRIGHTCOVE_CLIENT_SECRET,
    accountId: process.env.BRIGHTCOVE_ACCOUNT_ID
};

brightcoveProvider.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: 'brightcove-video'})
  • bus.query({role: 'provider', cmd: 'get', source: 'brightcove-playlist'})

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

// To create a collection based on a Brightcove playlist:
bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, {
    channel: 'abc',
    type: 'collectionSpec',
    source: 'brightcove-playlist',
    playlist: {id: '1234567890'}
});

// To create a video based on a Brightcove video:
bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, {
    channel: 'abc',
    type: 'videoSpec',
    source: 'brightcove-video',
    video: {id: '0987654321'}
});

Transform Functions

This library provides a default transform function for collections and assets. It is fine to use the default, but you can provide your own like this:

const brightcoveProvider = require('oddworks-brightcove-provider');
const bus = createMyOddcastBus();

const options = {
    bus: bus,
    collectionTransform: myCollectionTransform,
    videoTransform: myVideoTransform
};

brightcoveProvider.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 myVideoTransform will be called when the vimeo-collection and brightcove-video have respectively received a response from the Brightcove API.

The myCollectionTransform function will be called with 2 arguments: the spec object and the Brightcove API response object for a playlist. The myVideoTransform function will be called with 3 arguments: the spec object, the Brightcove API response object for a video, and the Brightcove API response objects for a video's sources.

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

Brightcove API Client

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

const brightcoveProvider = require('oddworks-brightcove-provider');

const client = brightcoveProvider.createClient({
    bus: bus,
    clientId: process.env.BRIGHTCOVE_CLIENT_ID,
    clientSecret: process.env.BRIGHTCOVE_CLIENT_SECRET,
    accountId: process.env.BRIGHTCOVE_ACCOUNT_ID
});

Client Methods

All methods return a Promise.

  • client.getAccessToken({})
  • client.getPlaylistCount({})
  • client.getPlaylists({})
  • client.getPlaylist({})
  • client.getVideosByPlaylist({playlistId})
  • client.getVideoCountByPlaylist({playlistId})
  • client.getVideoCount({})
  • client.getVideos({})
  • client.getVideo({videoId})

See lib/client.js for more documentation and options.

Query Strings

Some methods support query strings. Simply provide the {query} key a hash of the query strings to use. This is handy for certain endpoints like list endpoints.

List endpoints such as client.getVideos() or client.getPlaylists() are pageable. The default number of items per page is 20. If your account contains more than 25 videos or playlists, you will need to pass query params in order to fetch the rest of your data. Use the methods client.getPlaylistCount() and client.getVideoCount() to know how many results are available.

Example:

const query = {
  limit: 20,
  offset: 20
};

client
  .playlists({query})
  .then(res => {
    console.log(JSON.stringify(res, null, 2));
  });

Command Line Interface

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

bin/brightcove --help

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

To get help with commands:

bin/brightcove list --help
bin/brightcove req --help

License

Apache 2.0 © Odd Networks