Table of content

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, Dailymotion’s Verified Partners can launch an ad break with up to 24 commercials per hour. When the 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 a commercial 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 the live_ad_break_launch=1 field 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://api.dailymotion.com/video/${VIDEO_ID}"

You may also be interested in the live_ad_break_end_time field – to know the estimated time of the end of the commercial break (45 sec between two commercials) and the live_ad_break_remaining field – to know how many ads you can send during the coming hour.

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': 'password',
  'client_id': '<Your API Key>',
  'client_secret': '<Your API Secret>',
  'username': '<Your Username>',
  'password': '<Your Password>'
}
 
response = requests.post('https://api.dailymotion.com/oauth/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://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 Partner yet?

Become one of Dailymotion’s Partners to monetize your content, create a channel and enjoy content management, distribution and analytics tools.