I’m trying to get the size of a YouTube video. I’m using a Gdata API call to retrieve the basic informations (title, URLs, thumbnails and categories) but I can’t find the vi
If you want to get dimensions for the example video from the question:
Then try this URL, using Noembed:
It will return the following JSON:
{
"version": "1.0",
"title": "まるです。",
"author_name": "mugumogu",
"provider_url": "https://www.youtube.com/",
"width": 459,
"height": 344,
"thumbnail_height": 360,
"type": "video",
"thumbnail_width": 480,
"provider_name": "YouTube",
"url": "https://www.youtube.com/watch?v=z_AbfPXTKms",
"author_url": "https://www.youtube.com/user/mugumogu",
"html": "\n\n",
"thumbnail_url": "https://i.ytimg.com/vi/z_AbfPXTKms/hqdefault.jpg"
}
It also supports JSONP for cross-origin requests:
For more info see this answer:
A simple demo using jQuery:
var id = 'z_AbfPXTKms';
var url = 'https://www.youtube.com/watch?v=' + id;
$.getJSON('https://noembed.com/embed',
{format: 'json', url: url}, function (data) {
alert('Dimensions: ' + data.width + 'x' + data.height);
});
See DEMO on JSBin.