Moran Talmon
Moran Talmon

Reputation: 595

Show thumbnails from private vimeo videos

I built a website with videos from vimeo. I want to show thumbnails from those videos on my site, but the normal API access won't help. The videos are private and can be accessed only in this site How can I get those thumbnails? Thanks

Upvotes: 2

Views: 4101

Answers (2)

Moran Talmon
Moran Talmon

Reputation: 595

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();
        }
    }
}

Upvotes: 0

Dashron
Dashron

Reputation: 3998

The API you linked is an old, deprecated API. The new API (developer.vimeo.com/api) will give you all the information you need.

You can learn more on the getting started page: https://developer.vimeo.com/api/start

Once you have a token, you can access your images from the direct video endpoint (https://api.vimeo.com/videos/{video_id}), Or from a collection of videos (such as https://api.vimeo.com/me/videos for your videos, or https://api.vimeo.com/channels/{channel_id}/videos for a channel's videos)

Upvotes: 2

Related Questions