Uploading a video on your Dailymotion's account can be done programmatically using our API. Below are described the different steps to follow in order to successfully upload content.
Note: a quota applies to video upload, please refer to the rate limit section.
As uploading a video is an action that impacts one's account, you need to be authenticated with the account on which the video is going to belong to and request the manage_videos
scope. See the authentication guide for more information on how to authenticate the user and request an access token for our API calls. You will have to pass the returned access token to each of the following calls.
Perform a GET request to https://api.dailymotion.com/file/upload
to retrieve an upload URL. Don't forget to provide your access token to the request. The upload_url
will be returned along with the progress_url
(the endpoint is described in more details at /file/upload
).
curl -H "Authorization: Bearer ${ACCESS_TOKEN}" \
"https://api.dailymotion.com/file/upload"
The video can actually be uploaded to the upload_url retrieved above by making a POST HTTP request using the multipart/form-data content type. The video data has to be contained in a file
field:
curl -X POST \
-F 'file=@/path/to/your/video.mp4' \
'<UPLOAD_URL>'
Once the POST HTTP request is finished, the upload server will return a JSON object containing several fields, you only need the url
one for the next steps.
Note:
upload_url
.With the video URL you just retrieved (url field in the returned response), you can perform a POST HTTP
request to https://api.dailymotion.com/me/videos
, with a url=<URL>
field. This API call will create the video on your account. The identifier of the newly created video will be returned in the response, in the response.id
field.
curl -X POST -H "Authorization: Bearer ${ACCESS_TOKEN}" \
"https://api.dailymotion.com/me/videos"
If you are an MCN with a specific permissions set by your content manager, you can set your content provider id on videos.
curl -X POST -H "Authorization: Bearer ${ACCESS_TOKEN}" \
-d "content_provider=YOUR_CONTENT_PROVIDER_NAME" \
-d "content_provider_id=CONTENT_PROVIDER_ID" \
"https://api.dailymotion.com/me/videos"
Once the video is created, it doesn't mean it is published. You have to perform another POST request on https://api.dailymotion.com/video/<VIDEO_ID>
URL along with the fields you want to modify. Some fields like title
, tags
and channel
are mandatory before you can publish the video. Set those fields, and toggle the published
field to true to publish the video.
curl -X POST -H "Authorization: Bearer ${ACCESS_TOKEN}" \
-d 'published=true' \
-d 'title=<TITLE>' \
-d 'channel=<CHANNEL>' \
-d 'tags=<TAGS>' \
https://api.dailymotion.com/video/<VIDEO_ID>
Note:
url
field (set to your video source url).curl -X POST \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-d 'url=<VIDEO_URL>' \
-d 'title=Dailymotion cURL upload test' \
-d 'tags=dailymotion,api,sdk,test' \
-d 'channel=videogames' \
-d 'published=true' \
"https://api.dailymotion.com/videos"
We provide a resume function for uploading videos. In this case, you have to replace /upload by /rupload in the upload url. The protocol is described in this NGinx module page.
$url = $api->uploadFile('/path/to/your/video.mp4');
$api->post(
'/videos',
array(
'url' => $url,
'title' => 'Dailymotion PHP SDK upload test',
'tags' => 'dailymotion,api,sdk,test',
'channel' => 'videogames',
'published' => true,
)
);
// get an upload url
DM.api('/file/upload', function (response)
{
//upload the video and get the url
var xhr = new XMLHttpRequest();
xhr.open('POST', response.upload_url, true);
var formData = new FormData(document.getElementById("fileDomId"));
xhr.send(formData);
// check when video is uploaded
xhr.onreadystatechange = function ()
{
if (xhr.readyState == 4)
{
// create the video object and publish the video
DM.api(
'/videos',
'post',
{
url: JSON.parse(xhr.response).url,
title: 'Dailymotion PHP SDK upload test',
tags: 'dailymotion,api,sdk,test',
channel: 'videogames',
published: 'true'
}
);
}
}
});
d = dailymotion.Dailymotion()
d.set_grant_type('password', api_key=API_KEY, api_secret=API_SECRET,
scope=['manage_videos'], info={'username': USERNAME, 'password': PASSWORD})
url = d.upload('./video.mp4')
d.post('/me/videos',
{'url': url, 'title': 'MyTitle', 'published': 'true', 'channel': 'news'})