BS Youtube Connector

The BS Youtube Connector allows synchronizing videos uploaded, modified, or deleted in the Contentserv DAM to Youtube. For each video uploaded Youtube will generate a Youtube ID, which can be written back to an attribute of the video in the Contentserv DAM. In such a scenario Youtube will work as a kind of Content Delivery Network, that allows the streaming of your videos all over the world with a great performance and high availability.

Setting up the Connector

Youtube provides a REST API that allows creating, updating and deleting videos. The connector uses this API to synchronize DAM videos in selected folders. All changes to these folders are processed using the BS Skills Event Queue.

To set up the connector two settings are required:

  • Setting up the Youtube API Credentials

  • Setting up the event queue by creating and scheduling an Active Script with the type “BS Event Queue”

Setting up the Youtube API Credentials

The BS Youtube Connector stores the API credentials in the global Settings at System Preferences / Settings / BS / Youtube Connector:

The API requires an OAuth Client ID and Secret. Use the “Click here and create an OAuth Client ID” to get to the Google Cloud Console. If you do not yet have an account, create it.

If you do not yet have a project, click on “Create Project”:

Provide at least the Project Name and click “Create”:

The new project dashboard will be shown:

Then click on APIs & Services > OAuth consent screen:

 

Choose “External” or “Internal” and click “Create”:

Fill out the form to describe the App:

Scroll down to provide more information about the App domain:

Add test users during the testing phase:

In the next step add the Youtube API to the BS Youtube Connector project by clicking on APIs & Services > Library:

Search for Youtube and select the “Youtube Data API v3”:

Click “Enable” to activate this API:

Finally, go to APIs & Services > Credentials:

Click “Create Credentials > OAuth client ID”:

Choose “Web application” as type and add the URL

http[s]://[domain]/[base]/admin/forward.php?forward=../[ProjectName]/modules/alaniyoutube/lib/CreateToken.php

as “Authorized redirect URIs”. In this example we used:

http://localhost/trunk/admin/forward.php?forward=../BSLive/modules/alaniyoutube/lib/CreateToken.php

Click “Create” and copy your credentials from the pop-up screen:

The Client ID and Secret have to be provided in the settings of the BS Youtube Connector:

Connecting the Youtube Connector with your Youtube Account

The OAuth concept defines, how a developer or app can access another user's account. To do this, the user has to declare, that she trusts the App through a consent process.

To start this process click in the Youtube Connector settings on “Click here to authenticate”:

Provide your email address with the Youtube account and choose the account or brand account:

Until the app is verified you can click on “Continue” if you trust the application (you can ):

Grant the connector to manage your Youtube account. It wil have to create and delete videos on your behalf:

Confirm your choice and click “Allow”:

Technically this actions stores an access token to the alaniyoutube/data/token.txt file along with a refresh token:

Once this is done, the connector can talk to your Youtube account.

Setting up the event queue

Navigate to the ActiveJobs area and create a new Active Script of type “BS Event Queue”:

Choose “MAM Files” as Event Type and select the “BS Youtube Connector”.

In the Event Filter, you can specify which kind of videos should be synchronized by filtering for

  • Object Selection through Folders or Favorites

  • Node Type Filter (of course only End Nodes = Files in the DAM are relevant)

  • Workflow State Filter (if you want to synchronize videos only when reaching certain workflow states)

If you want to store the Youtube IDs created for your videos back to the DAM asset you can create a DAM attribute of type simple text field or read-only text field and select it here as “Youtube ID Field”:

In our case we created this field here:

Along with this field, we also create a Youtube preview field to display a Youtube viewer directly with the DAM video asset. This is of course optional, but can be done with a placeholder type “Youtube Preview” that comes with the BS Skills package:

In our sample any DAM video then has these two attributes:

Running the Connector

Finally, you can run the connector.

First choose the required “Events from” date to make sure, to transfer all videos starting from a certain time. Feel free to set this some date back in 2000 to make sure, all videos are transferred intially.

When the “Events from update” checkbox is activated, the script will automatically update the “Events from” after each successful run.

Note: This new date becomes only visible when you reload the Active Script.

In the Active Script Log, you can see, that the videos are uploaded. Click on a video to review the updated Youtube ID field and preview:

The videos are also available in your Youtube account:

Deleting Youtube Videos

When the DAM video asset is deleted, the connector will also delete the Youtube video the next time the event queue script is running.