Get Img Thumbnails from Vimeo

Get img thumbnails from Vimeo?

From the Vimeo Simple API docs:

Making a Video Request

To get data about a specific video,
use the following url:

http://vimeo.com/api/v2/video/video_id.output

video_id The ID of the video you want information for.

output Specify the
output type. We currently offer JSON,
PHP, and XML formats.

So getting this URL http://vimeo.com/api/v2/video/6271487.xml

    <videos> 
<video>
[skipped]
<thumbnail_small>http://ts.vimeo.com.s3.amazonaws.com/235/662/23566238_100.jpg</thumbnail_small>
<thumbnail_medium>http://ts.vimeo.com.s3.amazonaws.com/235/662/23566238_200.jpg</thumbnail_medium>
<thumbnail_large>http://ts.vimeo.com.s3.amazonaws.com/235/662/23566238_640.jpg</thumbnail_large>
[skipped]
</videos>

Parse this for every video to get the thumbnail

Here's approximate code in PHP

<?php

$imgid = 6271487;

$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$imgid.php"));

echo $hash[0]['thumbnail_medium'];

Get thumbnail image of Vimeo video WITHOUT making a request to the Vimeo API

I also emailed Vimeo API support, and below is the "official" response I received from their support group:

Hi there,

Thanks for your interest in the Vimeo API! Full documentation of the
Vimeo API can be found on our Developer Site:

https://developer.vimeo.com/api/guides/start

Sorry, but it's not possible to get a video's thumbnail links without
first making a request to one of our APIs
(oEmbed or our full-fledged
REST API). You can learn about these APIs here:

https://developer.vimeo.com/api/oembed/videos

https://developer.vimeo.com/api/guides/start

So - no way to get a thumbnail of a Vimeo video without making a REST request. Too bad.

Update: 2-Oct-2021
See @Parthiban post - Vimeo has updated their service / documentation:
https://developer.vimeo.com/api/oembed/videos

Get Vimeo thumbnails for private videos

oEmbed can be used to get a video's thumbnail links, depending on the video's privacy settings.

First off, oEmbed will only return metadata when the video has embed privacy set to "Embed Anywhere" or "Only on site I choose". A video with its embed privacy to "Embed Nowhere" will return 403.

Videos with these viewing privacy settings will return "full" metadata (including thumbnail links):

  • Anyone
  • Only people with the private link (must use the complete video url)
  • Hide this video from vimeo.com

Videos with these viewing privacy settings will only return the embed code:

  • Only people I follow
  • Only people I choose
  • Only people with a password

oEmbed documentation can be found here: https://developer.vimeo.com/apis/oembed

Get vimeo thumbnail image through SSL

If the host is b.vimeocdn.com you can use https://secure-b.vimeocdn.com/ts/449/060/449060084_100.jpg to access the images over secure.

We are in the process of rolling out a new image system which will use the same host for secure and insecure. If the host of the image is i.vimeocdn.com then you can use https without changing the host.

Show thumbnails from private vimeo videos

This is a class with options for Large, Medium and Small images.

 namespace VimeoWrapper
{
public enum ThumbnailSize { Large, Medium, Small };
public enum VimeoErrors { NotFound, SizeNotExist, NetError }
public static class VimeoHelper
{
public static string GetVideoThumbnail(string videoid, ThumbnailSize tns = ThumbnailSize.Large)
{
string query = String.Format("https://api.vimeo.com/me/videos/{0}", videoid);

string accessToken = "Token from API";

WebClient wc = new WebClient();

wc.Headers.Add("Authorization", "bearer " + accessToken);

string result;

try
{
result = wc.DownloadString(query);
}
catch (System.Net.WebException e)
{
return VimeoErrors.NotFound.ToString();
}

try
{
dynamic jsonResult = JValue.Parse(result);
switch (tns)
{
case ThumbnailSize.Large:
return jsonResult.pictures.sizes[5].link;
case ThumbnailSize.Medium:
return jsonResult.pictures.sizes[3].link;
case ThumbnailSize.Small:
return jsonResult.pictures.sizes[1].link;
}
}
catch (JsonReaderException e)
{
return VimeoErrors.SizeNotExist.ToString();
}
catch (Exception e)
{
return VimeoErrors.NetError.ToString();
}

return VimeoErrors.NetError.ToString();
}
}
}


Related Topics



Leave a reply



Submit