I have implemented the following Bash script with which I'm trying to upload videos to my Dailymotion account. All the curl
requests return JSON responses as listed on the official API documentation pages. However, my video fails to show up in my account. What am I doing wrong here?
#!/bin/bash
curl -s --output out.txt --data 'grant_type=password&client_id=<My-ID>&client_secret=<My-Secret>&username=<My-Username>&password=<My-password>&scope=read+write' https://api.dailymotion.com/oauth/token
var1=$(grep "access_token" out.txt | cut -d: --complement -f1)
acc_token=$(echo $var1 | cut -d, -f1 | cut -d\" --complement -f1 | cut -d\" -f1)
curl -s --output out.txt -i https://api.dailymotion.com/file/upload?access_token="$acc_token"
upload_url=$(grep "upload_url" out.txt | cut -d: --complement -f1 | cut -d\" --complement -f1 | cut -d\" -f1 | sed 's/\\//g')
curl -s --output out.txt -F 'file=@/home/zahaib/video.mp4' "$upload_url"
video_url=$(grep "url" out.txt | cut -d: --complement -f1-10 | cut -d\" --complement -f1 | cut -d# -f1 )
curl -s --output out.txt -d $video_url https://api.dailymotion.com/me/videos?access_token="$acc_token"
video_id=$(grep "id" out.txt | cut -d: --complement -f1 | cut -d\" --complement -f1 | cut -d\" -f1 )
curl -s --output out.txt -d 'title=Vid&channel=sport&tags=was' https://api.dailymotion.com/video/"$video_id"/access_token="$acc_token"
curl -s --output out.txt -d 'published=true' https://api.dailymotion.com/video/"$video_id"/access_token="$acc_token"
There's a typo in your script on the last two lines:
https://api.dailymotion.com/video/"$video_id"/access_token="$acc_token"
Instead of:
https://api.dailymotion.com/video/"$video_id"/?access_token="$acc_token"
It's right there, in your out.txt:
{
"error":{
"code":501,
"message":"Invalid method name: POST \/video\/<xid>\/access_token=<redated>.",
"type":"invalid_method"
}
}