Vimeo:从API获取下载链接



我有Vimeo PRO,我正在尝试获得下载链接,以便最终用户可以下载视频源。然而,由于缺乏文档,很难弄清楚这一点。

我正在尝试VimeoDotNet,但我无法进行身份验证,我正在执行以下操作:

var client = new VimeoClientFactory().GetVimeoClient(key, secret)
var downloadLink = client.GetVideo(video_id).download;

然而,对GetVideo的调用抛出了一个错误,说我必须首先进行身份验证,但我不知道该怎么做!

我也尝试过使用另一个VimeoClient,但它似乎没有实现下载链接部分。

有人能帮忙吗?或者更好的是,分享一个有效的例子。谢谢

两天后,我终于能够做到了,如果有人需要,我会分享我所做的。首先,下载这个库:

https://github.com/saeedafshari/VimeoDotNet3

在Visual Studio中打开并编译它。它非常简单,所以它立即编译。

然后引用您的项目中编译的DLL,并执行以下操作:

var VimeoClient3 = Vimeo.VimeoClient.ReAuthorize(_vimeoAccessToken, 
_vimeoAppConsumerKey, _vimeoAppClientSecret);
// videoId is the ID of the video as in the public URL (eg, 123874983)
var result = VimeoClient3.Request("/videos/" + videoId, null, "GET");
if (result == null)
{
throw new Exception("Video not found.");
}
if (result["download"] == null)
{
throw new Exception("Download link not available.");
}
foreach (var item in (ArrayList)result["download"])
{
var downloadLinkInfo = item as Dictionary<string, object>;
if (downloadLinkInfo == null) continue;
// For example, get the link for SD quality.
// As of today, Vimeo was returning an HD quality and a 'mobile' one
// that is for streaming.
if (string.Equals((downloadLinkInfo["quality"] as string), "sd", StringComparison.InvariantCultureIgnoreCase))
{
return downloadLinkInfo["link"] as string;
}
}

最新更新