Invalid thumbnail URL when uploading a video on dailymotion api - dailymotion-api

I use dailymotion api to upload video : https://api.dailymotion.com/me/videos
In most of the cases, it works well. But sometimes, I have this error :
{"error":{"more_info":"https://developer.dailymotion.com/api#error-codes","code":400,"message":"Invalid thumbnail URL","type":"invalid_parameter"}}
When I upload the video again with the same parameters, it works.
here is a piece of my C# code :
var dico = new Dictionary<string, string>();
dico.Add("access_token", accessToken);
dico.Add("url", config.Url);
if (!string.IsNullOrEmpty(config.ThumbnailUrl))
dico.Add("thumbnail_url", config.ThumbnailUrl);
var postContent = new FormUrlEncodedContent(dico);
var response = await httpClient.PostAsync("https://api.dailymotion.com/me/videos", postContent);
I Cannot give the thumbnail URL but it contains 287 characters. Is it a problem? Do I need to URL encode ?
Thanks for your help

URL of this video's raw thumbnail (full size respecting ratio).
Some users have the permission to change this value by providing an URL to a custom thumbnail. If you don't have the permission, the thumbnail won't be updated. Note: for live streams, the thumbnail is automatically generated every 5 mn by default; it is not possible anymore to manually refresh the preview.

Related

Images/Videos CDN URL - Detect file type/extension

I'm trying to implement Story Mention rendering according to IG messenger graph API.
IG webhooks sends the payload URL of the media as CDN URLs that are extensionless,
which means I can't detect the file type(could be any kind of image or a video file).
The purpose is to render the URL to an HTML element and to prevent saving some file extensions.
Did anybody find out how to get this information?
An example for IG CDN URL
https://lookaside.fbsbx.com/ig_messaging_cdn/?asset_id=17952754300482708&signature=AbxVoHUcW3qKGZvE0FwrbpSEKBqkYGH9wFDUY9xnywlxxek8lWtrTwE173Sxhta9jbp0bgDiL17IpyiI82vqHGNPUD1wdMUZphwQOggW-_877cCI1BxaY_aDUZ8hj5OwmHK9E8OnSybqtMVmGXCX_hBF399t1Hb44zspeL3d9NWb9rib
Python:
import requests
res = requests.head(url)
print res.headers
I was able to retrieve the content type by making a request with node-fetch.
const fetch = require('node-fetch');
const response = await fetch(mediaUrl, { method: 'HEAD' });
const contentType = response.headers.get('Content-Type');

How to use image in Adaptive Card w/o direct URL to the image

I would like to use user's profile image from MS graph in adaptive card. I have determined the API call I need to make is as follows
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/profilephoto_get
In this case I would be getting image as a binary data for a profile photo, that needs to converted into a base-64 string.
But, based on adaptive cards schema document looks like we should use URL property where value should be direct URL to the image
'url string Yes The URL to the image'
How should I approach this ? If there any way to use an IMAGE in Adaptive Card w/o direct URL to the image ??
You can use a data URI to encode the bytes directly into the payload. Something like this sample:
var photo = await client.Me.Photos[size].Content.Request().GetAsync();
var photoStream = new MemoryStream();
photo.CopyTo(photoStream);
var photoBytes = photoStream.ToArray();
return string.Format("data:image/png;base64,{0}",
Convert.ToBase64String(photoBytes));

Facebook Graph API object_id missing sometimes

I am using the Facebook Graph API to get the news feed of a user.
My request URL is:
xxxxxxxxxxxxxx/feed?fields=from,id,created_time,picture,link,object_id,message, likes.fields(id)
With the object_id, I want to get the big picture of the post, using the following url:
http://graph.facebook.com/OBJECT_ID/picture?type=normal
The picture return field is always filled, but the object_id is not being returned at some posts. Why is this? I really need the high res picture, and didn't find another way to acquire this..
The object_id is only returned if the attachment is a facebook object (e.g. an image uploaded by the user). Some stories in feed don't have a picture at all, and some pictures are not facebook objects (e.g. thumbnails for shared links).
Sometimes Facebook keeps a thumbnail of an image and stores an external link to the larger version of the image in the URL returned by the graph request. In order to access the images in either case, I used the code below, where smallURL is the URL returned by the graph request:
private String getRealURL(String smallURL){
if (smallURL.contains("url=http")){
String[] pieces = smallURL.split("url=");
pieces[1].replace("%2F", "//");
pieces[1].replace("%3A", ":");
return pieces[1];
}
else{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.setLength(0);
stringBuilder.append("http://graph.facebook.com/");
stringBuilder.append(item.getObjectID());
stringBuilder.append("/picture?type=large");
return stringBuilder.toString();
}
}
I also noticed that some FB posts didn't have {object_id} for large photos, but realized that the {picture} thumbnail URL contains the encoded URL of the original larger image:
https://external.xx.fbcdn.net/safe_image.php?d=AQBe9UvGd0vPbAHP&w=130&h=130&url=http%3A%2F%2Fskift.com%2Fwp-content%2Fuploads%2F2015%2F12%2Fpollution.jpg&cfs=1
--> contains -->
http://skift.com/wp-content/uploads/2015/12/pollution.jpg
So I check for {object_id}, and if not then try to extract the original URL from {picture}:
if(isset($post['object_id'])) {
echo "http://graph.facebook.com/".$post['object_id']."/picture";
}
elseif(isset($post['picture'])) {
echo urldecode(preg_replace('/&cfs.*/', '', preg_replace('/.*url=/', '', $post['picture'])));
}
else {
echo "no_large_image";
}

YouTube Video API Time Out

I am using the Xamarin Mono for Android Google API binding. I receive an HTTP 308 error, which is basically a timeout, when I upload a video that's larger than 75 MB. I am unable to cast my videosInsertRequest.RequestFactory to GDataRequestFactory and set the time out. No GDataRequestFactory exists. The request factory is of type ICreateHttp and it's create method returns a HttpWebRequest. Is there another way to set the YouTubeRequest's time out property or upload the videos another way?
GoogleAuthenticator auth2;
YoutubeService yt = new YoutubeService (auth2);
string name = String.Format("{0} {1}", etStatusUpdate.Text, DateTime.Now.ToString());
var videosInsertRequest = yt.Videos.Insert (Helpers.MakeVideo (name, etStatusUpdate.Text), "snippet,statistics,status", MakeVideoFileStream (), VIDEO_FILE_FORMAT);
//((GDataRequestFactory)videosInsertRequest.RequestFactory).Timeout = 9999999;
videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
I would suggest you to use Data API v3.
YouTube Direct Lite project has uploads for Android.

YouTube v3 API (.NET) - Get URI of newly posted video resource?

After scouring the v3 API documentation (and using the API explorer), I am not able to determine how to obtain the URI of a newly uploaded video resource (or any video resource).
I am aware that the video's ID is readily available and it is trivial to construct a URI from the ID. For example, I have this extension method:
public static Uri GetUri(this Video video)
{
var uriBuilder = new UriBuilder
{
Scheme = Uri.UriSchemeHttp,
Host = "youtu.be",
Path = video.Id,
};
return uriBuilder.Uri;
}
However, it seems strange that the video resource would not include a few different URLs (regular, shortened and embed-able come to mind).
I also recognize I am probably over thinking this because the only volatile part of the URL is the video ID. I guess I could always put the host name in a config file :)
Thoughts and comments are appreciated.
Regards,
You can get the video ID from the upload response once your request is executed.
YouTube API samples have a great upload example for this.
Once you have the video id, you can construct the full URL as
youtube.com/watch?v={video_id}
youtu.be/{video_id}

Resources