A simple youtube-dl library for C#.
See the main page for youtube-dl for more information.
-
In the Nuget package manager console, run
PM> Install-Package NYoutubeDL
-
For DotNet Core apps, edit your project.json dependencies
"NYoutubeDL": "0.1.1"
-
Manually download nupkg from NuGet Gallery.
See the documentation for youtube-dl first to understand what it does and how it does it.
-
Create a new YoutubeDL client:
var youtubeDl = new YoutubeDL();
-
Options are grouped according to the youtube-dl documentation:
youtubeDl.Options.FileSystem.Output = "/path/to/downloads/video.mp4"; youtubeDl.Options.PostProcessing.ExtractAudio = true; youtubeDl.VideoUrl = "http://www.somevideosite.com/videoUrl"; // Or update the binary youtubeDl.Options.General.Update = true; // Optional, required if binary is not in $PATH youtubeDl.YoutubeDlPath = "/path/to/youtube-dl";
-
Subscribe to the console output (optional, but recommended):
youtubeDl.StandardOutputEvent += (sender, output) => Console.WriteLine(output); youtubeDl.StandardErrorEvent += (sender, errorOutput) => Console.WriteLine(errorOutput);
-
Start the download:
// Just let it run youtubeDl.Download(); // Or provide video url youtubeDl.Download("http://videosite.com/videoUrl"); // Or start the download and monitor it using a process object Process ydlDownloadProcess = youtubeDl.Download();