YouTubeStreamDownloader is a .NET 8 package that allows developers to interact with YouTube. It provides functionality to retrieve video metadata, download videos, extract audio, get subtitles, and fetch playlists and channel information using the YoutubeExplode library.
$ dotnet add package YouTubeStreamDownloaderYouTubeStreamDownloader is a .NET 8 package that allows developers to interact with YouTube.
It provides functionality to retrieve video metadata, download videos, extract audio, get subtitles, and fetch playlist & channel details using the YoutubeExplode library.
✅ Retrieve Video Metadata (title, duration, author, etc.)
✅ Download YouTube Videos (highest quality available)
✅ Extract & Download Subtitles (SRT format)
✅ Fetch Playlists & Channel Videos
✅ Supports Dependency Injection (DI)
You can install YouTubeStreamDownloader via NuGet:
dotnet add package YouTubeStreamDownloader
OR via Package Manager:
Install-Package YouTubeStreamDownloader
IYouTubeMetadataService downloader = new YouTubeMetadataService(new YoutubeClient());
var video = await downloader.GetVideoInfoAsync(TEST_VIDEO_URL);
Console.WriteLine($"Title: {video.Title}");
Console.WriteLine($"Duration: {video.Duration}");
Console.WriteLine($"Author: {video.Author}");
IYouTubeMetadataService downloader = new YouTubeMetadataService(new YoutubeClient());
var outputPath = "C:\\Videos";
string filePath = await downloader.DownloadVideoAsFileAsync(TEST_VIDEO_URL, outputPath);
Console.WriteLine($"Video downloaded successfully: {filePath}");
using Microsoft.Extensions.DependencyInjection;
using YouTubeStreamDownloader.Services;
var services = new ServiceCollection();
services.AddYouTubeMetadataService();
var provider = services.BuildServiceProvider();
var metadataService = provider.GetRequiredService<IYouTubeMetadataService>();
var playlists = await metadataService.GetAllPlaylistsAsync("https://www.youtube.com/@YourChannel");
foreach (var playlist in playlists)
{
Console.WriteLine($"{playlist.Title}: {playlist.Url}");
}
using Microsoft.Extensions.DependencyInjection;
using YouTubeStreamDownloader.Services;
var provider = new ServiceCollection()
.AddYouTubeMetadataService()
.BuildServiceProvider();
var metadataService = provider.GetRequiredService<IYouTubeMetadataService>();
var videos = await metadataService.GetAllVideosFromPlaylistAsync("https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID");
foreach (var video in videos)
{
Console.WriteLine($"{video.Title}: {video.Url}");
}
To use YouTubeStreamDownloader in an ASP.NET Core or Console Application, register it in Program.cs:
using Microsoft.Extensions.DependencyInjection;
using YouTubeStreamDownloader.Services;
var builder = WebApplication.CreateBuilder(args);
// Register the service
builder.Services.AddYouTubeMetadataService();
var app = builder.Build();
For Singleton DI:
builder.Services.AddYouTubeMetadataSingletonService();
Unit tests use NSubstitute for mocking and FluentAssertions for validation.
Run all tests:
dotnet test
Follow these steps:
git clone https://github.com/your-username/YouTubeStreamDownloader.git
git checkout -b feature/your-feature-name
git commit -m "Added new feature"
git push origin feature/your-feature-name
YouTubeStreamDownloader is licensed under the MIT License.
👤 Author: Shady Nagy
📧 Email: info@ShadyNagy.com
📌 GitHub: ShadyNagy
🌍 Website: https://shadynagy.com