Skip to content

Plugins

The technology of plugins is a very flexible mechanism implemented in the Telebreeze IPTV/OTT Platform, which allows to extend functionality of the video platform without the need to modify its core code.

Plugins may be used for integration with the following types of external services:
- content preparation (live and VOD transcoders), content delivery, and content protection servers; - payment gateways (Stripe, Orange Mone, etc.) and billing systems; - notification servers and services (SMTP, SMS, Push, and others); - geo-ip filtering servers; - metadata servers for content description (TMDB, OMDB, IMDB, and similar); - authorization services (SSO-servers, social networks, and others); - content providers (3rd party systems, which have API for content sharing); - EPG services (providers of the electronic program guides for TV channels).

Basic Plugin Composition

A basic plugin is a zip-archive with a set of files:

  • package.json
  • config.json
  • index.js

Some other files may be included in the plugin depending on its functionality. For example, an additional code-file or an image file with the logo of an external payment system, which needs to be displayed in the end-user’s applications.

package.json

“package.json” describes general information about a plugin in JSON-format according to the the Node.JS package and has the following basic parameters:

Key Name Value Type Value Description
name String Internal human readable identifier of the plugin, which must be unique within the platform.
type String "common.js" determines the type of the plugin as per Node.JS package manager documentation. This value must remain the same and must not change.
dependencies Object Set of dependencies for the plugin in a format of “name”:”path”
private Boolean Optional key. If "true" is set for this parameter then availability of the plugin will be determined by the license limitations for the IPTV/OTT Platform.
main String “index.js” is the name of the main file containing code of the plugin in JavaScript. This value must remain the same and must not change.

config.json

“config.json” describes setting of the plugin in JSON-format and has the following parameters:

Key Name Value Type Value Description
version String Version of the plugin assigned by the developer.
title String Internal parameter defined in the locales that sets the plugin’s title, which is displayed in the Operator’s Dashboard.
description String Internal parameter defined in the locales that sets the plugin’s description, which is displayed in the Operator’s Dashboard.
type String Determines the type of the plugin and can take one of the following values:
  • “server”
  • “payment”
  • “notification”
  • “geoip”
  • “metadata”
  • “authorization”
  • “content”
  • “epg”
  • name String Internal human readable identifier of the plugin, which must be unique within the IPTV/OTT Platform. This parameter must have the same value as defined for the “name” key in the “package.json” file.
    locales Set of Objects Set of objects defining internal parameters such as plugin’s title and description for various localization languages of the Operator's Dashboard. Two-letter codes for localization languages are used according to the ISO 639-1 standard. Only two localization languages (“en” and “ru”) are supported in the dashboard at the moment, therefore locales defined for other languages won’t be displayed in the Dashboard yet.
    parameters Set of Objects Set of objects defining parameters of the plugin. For examples of the payment plugins the following parameters are used:
  • “paymentTypes” - defines the types of payments for which this plugin may be used. Only the following values are allowed for this key:
    1. “balance” - top-up of a subscriber’s internal balance;
    2. “content” - purchase of a single content item, i.e. movie, series, show, shop item;
    3. “subscription” - purchase of a subscription.
  • “type” - defines the type of interaction within the IPTV/OTT platform. Only the following values are allowed for the key:
    1. “balance” - works without redirection to external resources, such as an external payment system;
    2. “external” - requires redirection to an external resource for completion of operations.
  • “image” - path to an image-file containing the logo of the payment system, which will be displayed for this payment method in the end-users application;
  • “webHook” - boolean value, which indicates whether web-hooks are used for this payment system or not.
  • instanceProps Set of Objects Set of objects defining properties of the plugin, which need configuration at the Operator’s Dashboard, when an instance of the plugin is created. Each object, i.e. plugin’s property, may have the following set of parameters:
  • “type” - type of the property. The following types of property may be used: “string”, “number”, “checkbox”, “select”, “multiselect”;
  • “title” - title of the property displayed in the Operator’s Dashboard;
  • “name” - internal name of the property;
  • “placeholder” - sample value, which is displayed as a hint in the Operator’s Dashboard;
  • “defaultValue” - value, which is assigned to the property by default;
  • “data” - array of objects defining the set of values for properties of the types “select” or “multiselect”. Each object of the array must have two pairs of parameters: “label” and “value”, which define, respectively, displayed and internal values for the list of available options.
  • “index.js” and its Compilation

    “index.js” contains compiled JavaScript code of the plugin defining its functionality.
    The source code of the plugin is written in TypeScript as a more clear and readable analog of the JavaScript. In order to get the js-files from the TypeScript code it needs to be compiled.

    Compilation process includes the following steps:

    1. Install Node.JS runtime environment (https://nodejs.org/en/download), which is required to build the code of the plugins.
    2. Install Yarn package manager (https://classic.yarnpkg.com/lang/en/docs/install/) in order to manage dependencies between packages.
    3. Create a folder for Telebreeze packages in your file system. For example, [d:\telebreeze].
    4. Download and unzip “Telebreeze Framework”, “Telebreeze SDK”, and “Telebreeze Plugins”, which are the prerequisite packages for any plugin for the Telebreeze IPTV/OTT Platform, to the folder created on the previous step. As a result, three folders [framework], [sdk], and [plugins] should be created in the [d:\telebreeze].
    5. Download and unzip “Telebreeze Balance” and “Telebreeze Stripe” as samples of plugins for the Telebreeze IPTV/OTT Platform to the folder created at step 3. As a result, two subfolders [balance] and [stripe] should be created in the [d:\telebreeze\plugins].
    6. In the command prompt (e.g. “Command Line” or “PowerShell” for Windows) go to the [framework] folder and call yarn command in order to build dependencies for the framework.
    7. In the command prompt go to the [sdk] folder and call yarn command in order to build dependencies for the sdk.
    8. In the command prompt go to the [balance] folder and call yarn command in order to build dependencies for the balance plugin.
    9. In the command prompt go to the [stripe] folder and call yarn command in order to build dependencies for the stripe plugin.
    10. In the command prompt go to the [plugins] folder and call the ‘yarn build’ command in order to build js-files for the plugins. As a result, folders [dist/plugins] with two subfolders [balance] and [stripe] must be created in the folder created on Step 3. Each subfolder must contain js-file(s) with the JavaScript code of the plugins, which were compiled from the TypeScript source files, two JSON-files, and, possibly, some other files required for a plugin, such as plugin's image file, additional JS-files, etc.
    11. Compress the folder with the plugin name in the [dist\plugins] folder into a zip-file.
    12. Upload the distribution zip-file created on the previous step into the proper section of the Operator’s Dashboard.

    In the provided “index.ts” for the “Internal Balance Payment” plugin the main actions are made in the method PayWithBalance().
    If the method returns Promise.Resolve() then the operation is completed successfully.
    If the method returns Promise.Rejected() then the operation is failed.
    Log-messages are saved by the Logging.error() method into the “console.log” file, which is the docker container’s console output.

    Plugin Development

    In order to develop a new plugin the following steps need to be taken:

    1. Create a folder for the new plugin in the [plugins] folder along with the sample plugins.
    2. Copy files of a sample plugin into the new folder.
    3. Change values of the sample’s JSON-files to desired values.
    4. Rewrite the code of the “index.ts” file.
    5. Build the new plugin using the yarn build command.
    6. Compress the folder with the new plugin in the [dist\plugins] folder in a zip-file.
    7. Upload zip-file with the new archive into the proper section of the Operator’s Dashboard. To access it, in your operator account, click on your name at the top right.
      plugins.png