Vimeo API - 按质量获取视频的直接 link (C#)
Vimeo API - Getting video's direct link by quality (C#)
我有一个单用户应用程序,
在 Vimeo 的操场上,当做视频/{id} 时,我得到一个很大的 JSON 结果,其中包含:
"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..."
}
(我编辑了网址)
但是在我的代码中执行相同的调用时,整个 "files" 部分都丢失了(整个 json 结果看起来也不同):
这是我的代码,调用:
vc.Request("/videos/255898412", null, "GET");
请求方式:
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));
}
我的目标是直接获得 HLS link,以便在我的播放器中播放。
我怎样才能实现它?
谢谢
我今天也遇到了同样的问题
我的笨办法如下
- 使用3.1版本API
存在一个错误,即使用 API v3.4 的开发人员无法返回下载和文件密钥。 Vimeo 此后修复了该错误(截至 2018 年 2 月 23 日)。
从 API v3.4 开始,开发人员必须使用具有 video_files
范围的令牌对请求进行身份验证,以接收视频响应中的下载和文件密钥。
如果您使用 OAuth 工作流程生成令牌,则可以通过这种方式生成具有 video_files 范围的令牌:https://developer.vimeo.com/api/authentication#supported-scopes
希望这些信息对您有所帮助!
我有一个单用户应用程序,
在 Vimeo 的操场上,当做视频/{id} 时,我得到一个很大的 JSON 结果,其中包含:
"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..."
}
(我编辑了网址)
但是在我的代码中执行相同的调用时,整个 "files" 部分都丢失了(整个 json 结果看起来也不同):
这是我的代码,调用:
vc.Request("/videos/255898412", null, "GET");
请求方式:
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));
}
我的目标是直接获得 HLS link,以便在我的播放器中播放。 我怎样才能实现它?
谢谢
我今天也遇到了同样的问题
我的笨办法如下
- 使用3.1版本API
存在一个错误,即使用 API v3.4 的开发人员无法返回下载和文件密钥。 Vimeo 此后修复了该错误(截至 2018 年 2 月 23 日)。
从 API v3.4 开始,开发人员必须使用具有 video_files
范围的令牌对请求进行身份验证,以接收视频响应中的下载和文件密钥。
如果您使用 OAuth 工作流程生成令牌,则可以通过这种方式生成具有 video_files 范围的令牌:https://developer.vimeo.com/api/authentication#supported-scopes
希望这些信息对您有所帮助!