Launch an ad break during a live event

Streaming live events is a plan feature

Please reach out to your Dailymotion Account Manager or our Support Team to subscribe and set up the feature on your account.

Overview

During a live event, ad breaks can be launched with up to 24 commercials per hour. When an ad break is triggered, all viewers will simultaneously receive mid-roll advertising in their Player, composed of one or several ads depending on the input number.

To launch an ad break, you need to authenticate and request an access token with the manage_videos scope. Then, issue a POST HTTP request to https://api.dailymotion.com/video/<VIDEO_ID> with live_ad_break_launch=1 set to the number of advertisements you want to display (only one at the time).

curl --request POST \
   --header "Authorization: Bearer ${ACCESS_TOKEN}" \
   --data "live_ad_break_launch=1" \
   "https://partner.api.dailymotion.com/video/<VIDEO_ID>"

You may also be interested in:

Run recursive ad breaks using Python

📘

Make sure you have Python 2.7.9 or more recent version on your server.

Install requests:

$ pip install requests

Install JSON:

$ pip install json

Install crontab:

$ pip install crontab

Add your credentials and the live video ID you want to trigger ad break on, then save the script as adbreak.py.

import requests
import json
 
data = {
  'grant_type': 'client_credentials',
  'client_id': '<Your API Key>',
  'client_secret': '<Your API Secret>'
}
 
response = requests.post('https://partner.api.dailymotion.com/oauth/v1/token', data=data)
json_data = json.loads(response.text)
 
 
headers = {
    'Authorization': 'Bearer ' + json_data['access_token'],
}
 
data = {
  'live_ad_break_launch': '1'
}
 
response = requests.post('https://partner.api.dailymotion.com/video/<VIDEO ID>', headers=headers, data=data)
#json_data1= json.loads(response.text)

Run the command line on your server to make it recursive (ie. for 15 minutes, you will need to use */15 * * * *):

crontab */15 * * * *  /path/to/script
👍

Not a Pro yet?

Subscribe to one of our Dailymotion Pro offers to monetize your content, create a channel and enjoy content management, distribution and analytics tools.