Bulk Updating Brightcove Default Player

In this topic, you will learn how to update Brightcove Default Player from multiple accounts using curl, a shell script and Terminal.

Introduction

The curl statement shown in this document will loop over a number of accounts and update ONLY the Brightcove Default Player in those accounts to a desired Brightcove Player version. As a pre-requisite for the curl statement used to do the update and publish, it is shown how to get an access token to use in the curl statement.

Get access token

You need to have an access token that provides Player Read/Write access for all accounts on which you are going to use the curl statement. In Studio, from the Admin dropdown select API Authentication. Register a new application and select the desired accounts. For the Exposed Brightcove APIs choose Players > Read/Write and CMS > Videos > Read/Write.

API Authentication UI

After you save, copy the Client ID and Client Secret.

For more info on this process, see the Generating Access Tokens document.

Now to get your access token, use the client ID and client secret with this sample: OAuth API Sample: Get an Access Token. Remember, you may have to use this sample repeatedly as access tokens are only valid for 5 minutes.

curl statement

Create a folder where you will create a couple of files and from where you will run a script from Terminal. In that folder create a file named accountList.txt, and in the file simply copy and paste all the account IDs for which you want to update the Brightcove Default Player.

Now create another file named bulk-update.sh. Place the following curl statement in the file:

      #!/bin/bash

        #Loop through publisher IDs in accountlist.txt
        while read -r ACCOUNTID; do
        echo {account_id}ID

        #Update
        curl -X PATCH "https://players.api.brightcove.com/v1/accounts/ID/players/default/configuration" \
        -H "Authorization: Bearer YOUR_ACCESS_TOKEN_HERE" \
        -H 'Content-Type: application/json' \
        -d '{"player":{"template":{"version":"6.34.3"}}}'

        #Publish
        curl -X POST "https://players.api.brightcove.com/v1/accounts/ID/players/default/publish" \
        -H "Authorization: Bearer YOUR_ACCESS_TOKEN_HERE" \
        -H 'Content-Type: application/json' \
        -d '{"comment": "Updated to v6"}'

        #Wait 1 second then loop
        sleep 1
        done <accountList.txt
    

Of course, you will need to replace the two instances of YOUR_ACCESS_TOKEN_HERE with your actual access token. If it has been more than 5 minutes since your generated your access token, re-run the sample to get a new token. Also, you may use any version of the player, just update the version used, 6.34.3.

Lastly open a Terminal instance in the folder with the two files. To run the script enter:

      bash ./bulk-update.sh
    

The script both updates the player version, and publishes the player.