通过URL下载vimeo视频

时间:2016-06-08 11:01:46

标签: c# download webclient-download

我正在尝试通过C#代码实现vimeo视频,但正在下载的文件是HTML。谁能告诉我怎么做?下面你可以找到我实现的两个处理程序。两者都具有我已经描述的相同行为。

        Handle.GET("/testDownload", (Request r) =>
        {
            Response response = 0;

            try
            {
                WebClient webClient = new WebClient();
                webClient.DownloadFile("https://player.vimeo.com/video/140308351", @"c:\binte\test");
            }
            catch (Exception ex)
            {
                GlobalDictionary.errorLog.LogError("Error in test download handler : " + ex.Message);
            }

            response.Body = "success";

            return response;
        }, new HandlerOptions() { SkipMiddlewareFilters = true });

        Handle.GET("testDownloadVideo?url={?}", (string url, Request r) =>
        {
            Response response = 0;

            string fileName = "testDownload.mpeg";

            try
            {
                using (WebClient myWebClient = new WebClient())
                {

                    myWebClient.DownloadFileAsync(new Uri(url), fileName);
                }
            }
            catch (Exception ex)
            {
                GlobalDictionary.errorLog.LogError("Error in test download handler : " + ex.Message);
            }

            response.Body = "success";

            return response;
        }, new HandlerOptions() { SkipMiddlewareFilters = true });

编辑:经过一番研究后,我认为这是不可能的,除非我是视频的所有者,因此能够将API用于此目的。我会把问题保持开放,有一天这可能会改变。

0 个答案:

没有答案