Skip to content

Feature Release

Manojbabu edited this page Mar 20, 2026 · 1 revision

Ytdlp.NET

Complete Fluent Library for yt-dlp in .NET
Version 3 introduces a fully redesigned fluent API with thread-safe command execution, probes, and batch operations.


Table of Contents

  1. Overview

  2. Installation

  3. Migration from v2 → v3

  4. Core Concepts

    • YtdlpBuilder

    • YtdlpCommand

    • YtdlpProbe

  5. YtdlpBuilder Methods

    • General Options

    • Network Options

    • Video Selection Options

    • Download Options

    • Filesystem Options

    • Thumbnail Options

    • Verbosity & Simulation Options

    • Workgrounds (headers)

    • Video Format Options

    • Subtitle Options

    • Authentication Options

    • Post-Processing Options

    • SponsorBlock Options

  6. YtdlpCommand

    • ExecuteAsync

    • ExecuteBatchAsync

    • Events

  7. YtdlpProbe

  8. Examples

    • Single video download

    • Playlist download

    • Audio extraction

    • Subtitles & metadata

    • Probing

    • Batch downloads with concurrency

  9. Best Practices & Tips

  10. Error Handling


Overview

Ytdlp.NET v3 is a fully fluent .NET wrapper around yt-dlp, designed to provide:

  • Thread-safe execution of downloads and probes

  • Fluent configuration using YtdlpBuilder

  • Comprehensive events for progress, post-processing, and errors

  • Batch downloads with controlled concurrency

  • Full coverage of yt-dlp options

v3 is not backward-compatible with v2. The internal configuration is immutable and safe to reuse for multiple commands.


Installation

Install via NuGet:

Install-Package Ytdlp.NET -Version 3.0.0

Or in your .csproj:

<PackageReference Include="Ytdlp.NET" Version="3.0.0" />

Migration from v2 → v3

Key changes:

Feature | v2 | v3 -- | -- | -- Builder | Shared mutable YtdlpOptions | Immutable fluent YtdlpBuilder Thread-safety | None | Thread-safe by design with Interlocked guards Command execution | Single-use | Multi-instance with safe concurrent execution Events | Limited | Full progress, post-processing, and error events Probe | Minimal | Full stdout + stderr capture Options | Simple strings | Strongly-typed methods, full yt-dlp coverage

YtdlpCommand Usage

var command = builder.Build();

command.OnProgressDownload += (s, e) => Console.WriteLine($"Progress: {e.Progress}%");

command.OnErrorMessage += (s, msg) => Console.WriteLine($"Error: {msg}");

await command.ExecuteAsync("https://youtube.com/watch?v=xyz");

Batch Example:

var urls = new[] { "url1", "url2" };
var results = await command.ExecuteBatchAsync(urls, maxConcurrency: 3);

foreach (var (url, error) in results) { Console.WriteLine($"{url} => {(error == null ? "Success" : error.Message)}"); }


YtdlpProbe Usage

var probe = new YtdlpProbe(builder);
var info = await probe.GetInfoAsync("https://youtube.com/watch?v=xyz");

Console.WriteLine(info.Json);

  • Returns metadata without downloading

  • Captures stdout + stderr

  • Thread-safe


Examples

Single video download:

var builder = new YtdlpBuilder()
.WithOutputFolder("C:\Videos")
.WithFormat("best");

await builder.Build().ExecuteAsync("https://youtube.com/watch?v=abc123");

Audio extraction:

var builder = new YtdlpBuilder()
.WithOutputFolder("C:\Music")
.WithExtractAudio("mp3", 5);

await builder.Build().ExecuteAsync("https://youtube.com/watch?v=abc123");

Subtitles & Metadata:

var builder = new YtdlpBuilder()
.WriteVideoMetadata()
.WithDownloadSubtitles("en,ja", autoGenerated: true);

await builder.Build().ExecuteAsync("https://youtube.com/watch?v=abc123");

Batch with concurrency:

var urls = new[] { "url1", "url2", "url3" };
var command = builder.Build();

var results = await command.ExecuteBatchAsync(urls, maxConcurrency: 2);


Best Practices & Tips

  • Always use thread-safe builders (YtdlpBuilder) for multi-command scenarios

  • Use events to track progress and errors instead of polling

  • Use ExecuteBatchAsync for playlists or multiple downloads

  • Avoid overwriting files by using NoFileOverwrites() and NoPostOverwrites()


Error Handling

  • All yt-dlp errors are propagated as YtdlpException

  • Probe failures throw YtdlpException with stderr

  • Cancellation uses OperationCanceledException


This documentation is full exhaustive v3, ready for GitHub or NuGet.


If you want, I can also generate a fully formatted README.md with clickable table of contents, badges, and live code blocks that you can drop directly into the Ytdlp.NET repo. This would make it production-ready.

Do you want me to do that next?

Clone this wiki locally