Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用于在C中使用libvideo下载的代理#_C#_Proxy_Youtube_Youtube Dl - Fatal编程技术网

C# 用于在C中使用libvideo下载的代理#

C# 用于在C中使用libvideo下载的代理#,c#,proxy,youtube,youtube-dl,C#,Proxy,Youtube,Youtube Dl,有人熟悉libvideo吗?我在一个应用程序中有[libvideo][1] 如何将代理配置注入libvideo using VideoLibrary; void SaveVideoToDisk(string link) { var youTube = YouTube.Default; // starting point for YouTube actions var video = youTube.GetVideo(link); // gets a Video object w

有人熟悉libvideo吗?我在一个应用程序中有
[libvideo][1]

如何将代理配置注入
libvideo

using VideoLibrary;

void SaveVideoToDisk(string link)
{
    var youTube = YouTube.Default; // starting point for YouTube actions
    var video = youTube.GetVideo(link); // gets a Video object with info about the video
    File.WriteAllBytes(@"C:\" + video.FullName, video.GetBytes());
}

似乎
libvideo
不支持代理。因此,我必须使用youtube dl并更正上述代码

public static void YouTubeDownloaderWithProxy(string link, string path)
{
    Process youTube = new Process();
    try
    {
        string code = link.Split('/').LastOrDefault();
        string proxy = @"http://....:8585/";
        string youtubeUrl = @"https://www.youtube.com/watch?v=" + "code";

        youTube.StartInfo.UseShellExecute = true;
        youTube.StartInfo.CreateNoWindow = false;
        youTube.StartInfo.FileName = Application.StartupPath + @"\youtube-dl.exe";
        youTube.StartInfo.Arguments = $"--proxy {proxy} -o '{path}' {youtubeUrl}";

        youTube.Start();
        youTube.WaitForExit();
        youTube.Dispose();
    }
    catch (Exception e)
    {
        MessageBox.Show(e.Message);
    }

}