Language: EN


How to download YouTube videos from C# with YouTubeExplode

YouTubeExplode is a C# library that provides an interface for querying the metadata of YouTube videos, playlists, and channels.

With YoutubeExplode, we can easily perform a wide variety of tasks, such as downloading videos and playlists, searching for videos by keywords, getting information about videos and channels, and much more.

The library is designed to be intuitive and easy to understand. Additionally, there is a great deal of documentation and examples on the project page.

YoutubeExplode is compatible with .NET Standard 2.0, which means it can be used on any platform that supports this version of the framework, including Windows, Linux, and macOS.

Downloading YouTube videos may be against the terms of use and service in your country. Use it at your own risk

How to use YoutubeExplode

We can easily add the library to a .NET project through the corresponding Nuget package.

Install-Package YoutubeExplode

Here are some examples of how to use YoutubeExplode taken from the library documentation. For example, this is how we can obtain the metadata of a video,

using YoutubeExplode;

var youtube = new YoutubeClient();

var videoUrl = "";
var streamManifest = await youtube.Videos.Streams.GetManifestAsync(videoUrl);
var streamInfo = streamManifest.GetMuxedStreams().GetWithHighestVideoQuality();
var stream = await youtube.Videos.Streams.GetAsync(streamInfo);
await youtube.Videos.Streams.DownloadAsync(streamInfo, $"video.{streamInfo.Container}");

While to download the video stream itself, we would do,

using YoutubeExplode;

var youtube = new YoutubeClient();

// You can specify either the video URL or its ID
var videoUrl = "";
var video = await youtube.Videos.GetAsync(videoUrl);

var title = video.Title; // "Collections - Blender 2.80 Fundamentals"
var author = video.Author.ChannelTitle; // "Blender"
var duration = video.Duration; // 00:07:20

And if we wanted to work with a playlist instead of a video, we could do it like this,

using YoutubeExplode;

var youtube = new YoutubeClient();
var playlistUrl = "";

await foreach (var video in youtube.Playlists.GetVideosAsync(playlistUrl))
    var title = video.Title;
    var author = video.Author;

As we can see, it’s very straightforward. The library provides many more methods and options. Check the project page for more information.

YoutubeExplode is Open Source, and all the code and documentation is available in the project repository at