Search code examples
jsonvimeovimeo-api

Vimeo API - Getting video's direct link by quality (C#)


I have a single-user application,

in Vimeo's playground, when doing video/{id}, i get a big JSON result that contains:

"files": [
        {
            "quality": "hd",
            "type": "video/mp4",
            "width": 1920,
            "height": 1080,
            "link": "...link...",
            "created_time": "2018-02-15T13:46:25+00:00",
            "fps": 23.980000000000000426325641456060111522674560546875,
            "size": 3113207678,
            "md5": "b6beed65b699df870e481045178accc5",
            "link_secure": "...link..."
        },
        {
            "quality": "sd",
            "type": "video/mp4",
            "width": 640,
            "height": 360,
            "link": "...link...",
            "created_time": "2018-02-15T13:46:05+00:00",
            "fps": 23.980000000000000426325641456060111522674560546875,
            "size": 536864946,
            "md5": "af227a5526af15d2bce6ac951d6cf06b",
            "link_secure": "...link..."
        },
        {
            "quality": "sd",
            "type": "video/mp4",
            "width": 960,
            "height": 540,
            "link": "...link...",
            "created_time": "2018-02-15T13:46:05+00:00",
            "fps": 23.980000000000000426325641456060111522674560546875,
            "size": 1242328160,
            "md5": "1963f908509b14fd7a40dc46bfa6c519",
            "link_secure": "...link..."
        },
        {
            "quality": "hd",
            "type": "video/mp4",
            "width": 1280,
            "height": 720,
            "link": "...link...",
            "created_time": "2018-02-15T13:46:05+00:00",
            "fps": 23.980000000000000426325641456060111522674560546875,
            "size": 1977386604,
            "md5": "af38f067bd39f4f5bb71bad72f925337",
            "link_secure": "...link..."
        },
        {
            "quality": "hls",
            "type": "video/mp4",
            "link": "...link...",
            "created_time": "2018-02-15T13:46:25+00:00",
            "fps": 23.980000000000000426325641456060111522674560546875,
            "size": 3113207678,
            "md5": "b6beed65b699df870e481045178accc5",
            "link_secure": "...link..."
        }

(i edited the urls out)

but when doing the same call in my code, the whole "files" section is missing (also the whole json result looks different):

json

this is my code, the call:

vc.Request("/videos/255898412", null, "GET");

request method:

 public Dictionary<string, object> Request(
            string url,
            Dictionary<string, string> parameters,
            string method,
            bool jsonBody = true)
        { 
            var headers = new WebHeaderCollection()
            {
                { "Authorization", String.Format("Bearer {0}", AccessToken) }
            };
            method = method.ToUpper();
            url = apiRoot + url;
            string body = "";
            string contentType = "application/x-www-form-urlencoded";

            if (parameters != null && parameters.Count > 0)
            {
                if (method == "GET")
                {
                    url += "?" + Helpers.KeyValueToString(parameters);
                }
                else if (method == "POST" || method == "PATCH" || method == "PUT" || method == "DELETE")
                {
                    if (jsonBody)
                    {
                        contentType = "application/json";
                        body = jsonEncode(parameters);
                    }
                    else
                    {
                        body = Helpers.KeyValueToString(parameters);
                    }
                }
            }


            return  JsonConvert.DeserializeObject<Dictionary<string, object>>(Helpers.HTTPFetch(url, method, headers, body, contentType));

        }

My goal is to get the HLS direct link, to play it in my player . How can i achieve it?

Thanks


Solution

  • I also encountered the same problem today.

    My stupid solution is as follows.

    • Use 3.1 version of API