### Install and Setup Binaries in C# Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Use the Utils class to download required external dependencies like yt-dlp and FFmpeg programmatically. ```csharp // Install via NuGet Package Manager // PM> Install-Package YoutubeDLSharp // Download binaries programmatically using YoutubeDLSharp; // Download all required binaries at once await Utils.DownloadBinaries(skipExisting: true); // Or download individually await Utils.DownloadYtDlp(); // Download yt-dlp executable await Utils.DownloadFFmpeg(); // Download FFmpeg for video processing await Utils.DownloadFFprobe(); // Download FFprobe for media analysis await Utils.DownloadDeno(); // Optional: Download Deno for YouTube downloads ``` -------------------------------- ### Install YoutubeDLSharp via NuGet Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Use this command in the Package Manager Console to install the YoutubeDLSharp library. ```powershell PM> Install-Package YoutubeDLSharp ``` -------------------------------- ### Download Specific Range of Videos from Playlist Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt To download a specific range of videos (e.g., 5-10) from a playlist, specify the start and end parameters. You can also define the video and audio format, and recode to MP4 if needed. ```csharp // Download specific range (videos 5-10) var rangeResult = await ytdl.RunVideoPlaylistDownload( url: "https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf", start: 5, end: 10, format: "bestvideo+bestaudio/best", recodeFormat: VideoRecodeFormat.Mp4 ); ``` -------------------------------- ### Download Videos from a Playlist Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Download a specific range of videos from a YouTube playlist by providing start and end indices. ```csharp var res = await ytdl.RunVideoPlaylistDownload( "https://www.youtube.com/playlist?list=PLPfak9ofGSn9sWgKrHrXrxQXXxwhCblaT", start: 52, end: 76 ); ``` -------------------------------- ### Define basic OptionSet configuration Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Initialize an OptionSet instance with standard youtube-dl/yt-dlp properties. ```csharp var options = new OptionSet() { NoContinue = true, RestrictFilenames = true, Format = "best", RecodeVideo = VideoRecodeFormat.Mp4, Exec = "echo {}" } ``` -------------------------------- ### Initialize YoutubeDL Class in C# Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Configure the YoutubeDL instance with paths, output settings, and concurrency limits before executing download operations. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Options; // Create a new YoutubeDL instance with max 4 concurrent downloads var ytdl = new YoutubeDL(maxNumberOfProcesses: 4); // Configure paths (if binaries are not in PATH or current directory) ytdl.YoutubeDLPath = @"C:\tools\yt-dlp.exe"; ytdl.FFmpegPath = @"C:\tools\ffmpeg.exe"; // Configure output settings ytdl.OutputFolder = @"C:\Downloads\Videos"; ytdl.OutputFileTemplate = "%(title)s [%(id)s].%(ext)s"; ytdl.RestrictFilenames = false; // Allow special characters in filenames ytdl.OverwriteFiles = true; // Overwrite existing files ytdl.IgnoreDownloadErrors = true; // Continue on errors // Optionally use Python interpreter for yt-dlp ytdl.PythonInterpreterPath = @"C:\Python\python.exe"; // Change max concurrent processes at runtime await ytdl.SetMaxNumberOfProcesses(8); ``` -------------------------------- ### Initialize and Configure YoutubeDL Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Initialize the YoutubeDL class and set paths for yt-dlp, FFmpeg, and the output folder. This is useful if the binaries are not in the system's PATH or the current directory. ```csharp var ytdl = new YoutubeDL(); // set the path of yt-dlp and FFmpeg if they're not in PATH or current directory ytdl.YoutubeDLPath = "path\to\yt-dlp.exe"; ytdl.FFmpegPath = "path\to\ffmpeg.exe"; // optional: set a different download folder ytdl.OutputFolder = "some\directory\for\video\downloads"; ``` -------------------------------- ### Configure Download Options with OptionSet Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Use OptionSet to configure various download, output, conversion, subtitle, thumbnail, rate limiting, authentication, and proxy settings. This set of options can be passed to download methods to override default behavior. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Options; var ytdl = new YoutubeDL(); // Create an option set with various settings var options = new OptionSet() { // Download options NoContinue = true, // Don't resume partial downloads RestrictFilenames = true, // Restrict filenames to ASCII Format = "bestvideo[height<=1080]+bestaudio/best", // Output options Output = @"C:\Downloads\%(title)s.%(ext)s", NoOverwrites = true, // Video conversion RecodeVideo = VideoRecodeFormat.Mp4, MergeOutputFormat = DownloadMergeFormat.Mp4, // Subtitle options WriteAutoSub = true, SubLang = "en", // Thumbnail options WriteThumbnail = true, // Rate limiting LimitRate = "1M", // Limit download to 1MB/s // Authentication (for age-restricted content) Username = "user@example.com", Password = "password", // Cookies Cookies = @"C:\cookies.txt", // Proxy Proxy = "socks5://127.0.0.1:1080" }; // Use options with download var result = await ytdl.RunVideoDownload( url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", overrideOptions: options ); // Options that can have multiple values var multiOptions = new OptionSet() { PostprocessorArgs = new[] { "ffmpeg:-vcodec h264_nvenc", "ffmpeg_i1:-hwaccel cuda -hwaccel_output_format cuda" } }; ``` -------------------------------- ### Download youtube-dl/yt-dlp and FFmpeg Binaries Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Use these utility methods to download the necessary binaries for yt-dlp and FFmpeg if they are not already present. Deno is optional and used for YouTube downloads. ```csharp await YoutubeDLSharp.Utils.DownloadYtDlp(); await YoutubeDLSharp.Utils.DownloadFFmpeg(); await YoutubeDLSharp.Utils.DownloadDeno(); // optional, for YouTube downloads ``` -------------------------------- ### Execute Downloads with RunWithOptions Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Use RunWithOptions for direct execution of yt-dlp with a custom OptionSet, providing full control over the download process for single or multiple URLs. Supports progress tracking and argument display. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Options; var ytdl = new YoutubeDL(); // Run with custom options (multiple URLs) var options = new OptionSet() { Format = "best", Output = @"C:\Downloads\%(title)s.%(ext)s", WriteInfoJson = true, WriteThumbnail = true }; string[] urls = new[] { "https://www.youtube.com/watch?v=video1", "https://www.youtube.com/watch?v=video2" }; var result = await ytdl.RunWithOptions( urls: urls, options: options, ct: CancellationToken.None ); // Returns array of output lines foreach (var line in result.Data) { Console.WriteLine(line); } // Single URL variant with progress tracking var singleResult = await ytdl.RunWithOptions( url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", options: options, progress: new Progress(p => Console.WriteLine($"{p.Progress:P0}")), output: new Progress(Console.WriteLine), showArgs: true // Show yt-dlp arguments in output ); Console.WriteLine($"Output file: {singleResult.Data}"); ``` -------------------------------- ### Apply options to download methods Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Override default behavior by passing an OptionSet to download methods or using WithOptions. ```csharp var options = new OptionSet() { NoContinue = true, RestrictFilenames = true } var ytdl = new YoutubeDL(); var res = await ytdl.RunVideoDownload( "https://www.youtube.com/watch?v=bq9ghmgqoyc", overrideOptions: options ); ``` ```csharp var ytdl = new YoutubeDL(); var res = await ytdl.WithOptions("", options); ``` -------------------------------- ### Execute low-level YoutubeDLProcess Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Run the downloader process directly with event handlers for output and error streams. ```csharp var ytdlProc = new YoutubeDLProcess(); // capture the standard output and error output ytdlProc.OutputReceived += (o, e) => Console.WriteLine(e.Data); ytdlProc.ErrorReceived += (o, e) => Console.WriteLine("ERROR: " + e.Data); // start running string[] urls = new[] { "https://github.com/ytdl-org/youtube-dl#options" }; await ytdlProc.RunAsync(urls, options); ``` -------------------------------- ### Utils - Utility Methods for File and Binary Management Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Provides utility methods for sanitizing filenames, resolving executable paths, and downloading necessary binaries like yt-dlp and FFmpeg. Configure download timeouts and specify download directories. ```csharp using YoutubeDLSharp; // Sanitize filenames (removes/replaces invalid characters) string sanitized = Utils.Sanitize("Video: Title special *chars*"); // Result: "Video_ Title _with_ special _chars_" // Strict sanitization (ASCII only) string strictSanitized = Utils.Sanitize("Vidéo with àccénts", restricted: true); // Result: "Video_with_accents" // Get full path (searches PATH environment variable) string ytdlpPath = Utils.GetFullPath("yt-dlp.exe"); Console.WriteLine($"yt-dlp found at: {ytdlpPath}"); // Get binary names for current OS Console.WriteLine($"yt-dlp binary: {Utils.YtDlpBinaryName}"); Console.WriteLine($"FFmpeg binary: {Utils.FfmpegBinaryName}"); Console.WriteLine($"FFprobe binary: {Utils.FfprobeBinaryName}"); // Configure download timeout (default: 5 minutes) Utils.TimeoutSeconds = 600; // 10 minutes // Download all binaries to specific directory await Utils.DownloadBinaries( skipExisting: true, directoryPath: @"C:\\tools", downloadJSRuntime: true // Include Deno for YouTube ); ``` -------------------------------- ### Track Download Progress and Cancel Download Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Implement download progress tracking using `IProgress` and cancellation using `CancellationTokenSource`. This allows for real-time feedback and interruption of downloads. ```csharp // a progress handler with a callback that updates a progress bar var progress = new Progress(p => progressBar.Value = p.Progress); // a cancellation token source used for cancelling the download // use `cts.Cancel();` to perform cancellation var cts = new CancellationTokenSource(); // ... await ytdl.RunVideoDownload("https://www.youtube.com/watch?v=_QdPW8JrYzQ", progress: progress, ct: cts.Token); ``` -------------------------------- ### Download Audio with Conversion Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Extract and download the audio track from a video URL, converting it to a specified format like MP3. ```csharp var res = await ytdl.RunAudioDownload( "https://www.youtube.com/watch?v=QUQsqBqxoR4", AudioConversionFormat.Mp3 ); ``` -------------------------------- ### Download Entire Video Playlist Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Use RunVideoPlaylistDownload to download all videos from a YouTube playlist. Ensure the output folder is set before execution. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Options; var ytdl = new YoutubeDL(); ytdl.OutputFolder = @"C:\Downloads\Playlist"; // Download entire playlist var result = await ytdl.RunVideoPlaylistDownload( url: "https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf" ); Console.WriteLine($"Downloaded {result.Data.Length} videos"); ``` -------------------------------- ### Persist and load configuration files Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Save current OptionSet settings to a file or reload them for later use. ```csharp // Save to file var saveOptions = new OptionSet(); saveOptions.WriteConfigFile("path\\to\\file"); // Reload configuration OptionSet loadOptions = OptionSet.LoadConfigFile("path\\to\\file"); ``` -------------------------------- ### Save and Load OptionSet Configurations Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Persist OptionSet configurations to files compatible with yt-dlp's config format, and load them back. Also supports parsing options from command-line strings and merging/cloning OptionSet instances. ```csharp using YoutubeDLSharp.Options; // Create and configure options var options = new OptionSet() { Format = "bestvideo+bestaudio/best", Output = @"%(title)s.%(ext)s", RestrictFilenames = true, WriteThumbnail = true, WriteAutoSub = true, SubLang = "en" }; // Save to config file options.WriteConfigFile(@"C:\config\ytdlp-config.txt"); // Load from config file OptionSet loadedOptions = OptionSet.LoadConfigFile(@"C:\config\ytdlp-config.txt"); // Parse options from command-line style strings var parsedOptions = OptionSet.FromString(new[] { "--format bestvideo+bestaudio/best", "--output %(title)s.%(ext)s", "--restrict-filenames", "--write-thumbnail" }); // Override options (merge two option sets) var baseOptions = new OptionSet() { Format = "best" }; var overrides = new OptionSet() { RestrictFilenames = true }; var mergedOptions = baseOptions.OverrideOptions(overrides); // Clone an option set var clonedOptions = (OptionSet)options.Clone(); ``` -------------------------------- ### Add and Manage Custom Options Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Extend OptionSet with custom flags for forked yt-dlp versions or unsupported options. Custom options can be added, updated, deleted, and retrieved as string flags. ```csharp using YoutubeDLSharp.Options; var options = new OptionSet(); // Add custom options options.AddCustomOption("--my-custom-option", "value"); options.AddCustomOption("--enable-feature", true); options.AddCustomOption("--quality-level", 5); // Update existing custom option options.SetCustomOption("--my-custom-option", "new-value"); // Delete custom option options.DeleteCustomOption("--my-custom-option"); // Get all option flags as strings IEnumerable flags = options.GetOptionFlags(); foreach (var flag in flags) { Console.WriteLine(flag); } ``` -------------------------------- ### Manage custom options Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Add or update custom options for modified or forked versions of the downloader. ```csharp // add options.AddCustomOption("--my-custom-option", "value"); // set options.SetCustomOption("--my-custom-option", "new value"); ``` -------------------------------- ### YoutubeDLProcess - Low-Level Process Control Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Use YoutubeDLProcess for direct control over the yt-dlp process with event-based output handling. Configure Python path and subscribe to output/error events for real-time feedback. Supports cancellation and progress reporting. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Options; // Create low-level process wrapper var process = new YoutubeDLProcess(@"C:\\tools\\yt-dlp.exe"); // Optionally run via Python interpreter process.PythonPath = @"C:\\Python\\python.exe"; // Subscribe to output events process.OutputReceived += (sender, e) => { Console.WriteLine($"[OUTPUT] {e.Data}"); }; process.ErrorReceived += (sender, e) => { Console.WriteLine($"[ERROR] {e.Data}"); }; // Configure options var options = new OptionSet() { Format = "best", Output = @"C:\\Downloads\\%(title)s.%(ext)s" }; // Run the process string[] urls = new[] { "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }; int exitCode = await process.RunAsync(urls, options); Console.WriteLine($"Process exited with code: {exitCode}"); // Run with cancellation and progress var cts = new CancellationTokenSource(); var progress = new Progress(p => { switch (p.State) { case DownloadState.PreProcessing: Console.WriteLine("Preparing download..."); break; case DownloadState.Downloading: Console.WriteLine($"Downloading: {p.Progress:P0} at {p.DownloadSpeed}"); break; case DownloadState.PostProcessing: Console.WriteLine("Post-processing..."); break; case DownloadState.Error: Console.WriteLine($"Error: {p.Data}"); break; case DownloadState.Success: Console.WriteLine($"Completed: {p.Data}"); break; } }); exitCode = await process.RunAsync(urls, options, cts.Token, progress); ``` -------------------------------- ### Download Single Video in C# Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Perform video downloads with support for format selection, progress tracking, and cancellation tokens. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Options; var ytdl = new YoutubeDL(); ytdl.OutputFolder = @"C:\Downloads"; // Basic video download var result = await ytdl.RunVideoDownload("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); if (result.Success) { Console.WriteLine($"Downloaded to: {result.Data}"); } else { Console.WriteLine($"Errors: {string.Join("\n", result.ErrorOutput)}"); } // Download with specific format and conversion var result2 = await ytdl.RunVideoDownload( url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", format: "bestvideo[height<=1080]+bestaudio/best[height<=1080]", mergeFormat: DownloadMergeFormat.Mp4, recodeFormat: VideoRecodeFormat.Mp4 ); // Download with progress tracking and cancellation support var progress = new Progress(p => { Console.WriteLine($"State: {p.State}, Progress: {p.Progress:P0}"); Console.WriteLine($"Speed: {p.DownloadSpeed}, ETA: {p.ETA}"); }); var output = new Progress(line => Console.WriteLine(line)); var cts = new CancellationTokenSource(); // Cancel after 60 seconds cts.CancelAfter(TimeSpan.FromSeconds(60)); var result3 = await ytdl.RunVideoDownload( url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", progress: progress, output: output, ct: cts.Token ); ``` -------------------------------- ### Download Specific Items from Playlist with Progress Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Download individual videos from a playlist by providing an array of their indices. A progress handler can be attached to monitor the download state and progress. ```csharp // Download specific items by index var itemsResult = await ytdl.RunVideoPlaylistDownload( url: "https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf", items: new[] { 1, 3, 5, 7, 9 }, progress: new Progress(p => { if (p.State == DownloadState.PreProcessing) Console.WriteLine($"Processing video {p.VideoIndex}..."); else if (p.State == DownloadState.Downloading) Console.WriteLine($"Downloading: {p.Progress:P0}"); }) ); foreach (var file in itemsResult.Data) { Console.WriteLine($"Downloaded: {file}"); } ``` -------------------------------- ### Configure multi-value options Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Pass an array of strings to properties that support multiple values, such as post-processor arguments. ```csharp var options = new OptionSet() { PostprocessorArgs = new[] { "ffmpeg:-vcodec h264_nvenc", "ffmpeg_i1:-hwaccel cuda -hwaccel_output_format cuda" } }; ``` -------------------------------- ### Extract Audio from Video in C# Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Download and convert video streams to various audio formats using FFmpeg integration. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Options; var ytdl = new YoutubeDL(); ytdl.OutputFolder = @"C:\Downloads\Music"; // Extract audio as MP3 var result = await ytdl.RunAudioDownload( url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", format: AudioConversionFormat.Mp3 ); if (result.Success) { Console.WriteLine($"Audio saved to: {result.Data}"); } // Available audio formats: Best, Aac, Flac, Mp3, M4a, Opus, Vorbis, Wav var flacResult = await ytdl.RunAudioDownload( url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", format: AudioConversionFormat.Flac, progress: new Progress(p => Console.WriteLine($"Downloading: {p.Progress:P0}")) ); ``` -------------------------------- ### Extract Audio from Playlist Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Use RunAudioPlaylistDownload to download all videos from a playlist and convert them to a specified audio format, such as MP3. You can also specify a range of videos to process. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Options; var ytdl = new YoutubeDL(); ytdl.OutputFolder = @"C:\Downloads\Music\Album"; // Download playlist as MP3 audio files var result = await ytdl.RunAudioPlaylistDownload( url: "https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf", format: AudioConversionFormat.Mp3, start: 1, end: 20 ); Console.WriteLine($"Extracted {result.Data.Length} audio tracks:"); foreach (var audioFile in result.Data) { Console.WriteLine($" - {audioFile}"); } ``` -------------------------------- ### Download a Video Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Download a video from a given URL using the YoutubeDL class. The method returns the path to the downloaded file. ```csharp // download a video var res = await ytdl.RunVideoDownload("https://www.youtube.com/watch?v=bq9ghmgqoyc"); // the path of the downloaded file string path = res.Data; ``` -------------------------------- ### RunResult - Handling Download Results and Errors Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt The RunResult class encapsulates download operation results, providing success status and error information. Use EnsureSuccess to throw an exception on failure. ```csharp using YoutubeDLSharp; var ytdl = new YoutubeDL(); var result = await ytdl.RunVideoDownload("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); // Check success if (result.Success) { string downloadedFile = result.Data; Console.WriteLine($"Successfully downloaded: {downloadedFile}"); } else { // Handle errors Console.WriteLine("Download failed!"); foreach (var error in result.ErrorOutput) { Console.WriteLine($"Error: {error}"); } } // Use EnsureSuccess extension method to throw on failure try { var result2 = await ytdl.RunVideoDownload("https://invalid-url.com/video"); result2.EnsureSuccess(); // Throws if not successful } catch (Exception ex) { Console.WriteLine($"Download failed: {ex.Message}"); } ``` -------------------------------- ### Fetch Playlist Metadata Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Retrieve metadata for a YouTube playlist using RunVideoDataFetch with the 'flat' option set to true. This provides summary information about the playlist and its entries. ```csharp // Fetch playlist metadata var playlistResult = await ytdl.RunVideoDataFetch( url: "https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf", flat: true ); if (playlistResult.Success && playlistResult.Data.Entries != null) { Console.WriteLine($"Playlist: {playlistResult.Data.Title}"); Console.WriteLine($"Videos in playlist: {playlistResult.Data.Entries.Length}"); } ``` -------------------------------- ### Fetch Video Metadata Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Retrieve detailed metadata for a specific YouTube video without downloading it using RunVideoDataFetch. Options like 'flat' and 'fetchComments' can control the depth of information retrieved. ```csharp using YoutubeDLSharp; using YoutubeDLSharp.Metadata; var ytdl = new YoutubeDL(); // Fetch video metadata var result = await ytdl.RunVideoDataFetch( url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", flat: true, // Don't extract info for each video in playlist fetchComments: false // Skip fetching comments ); if (result.Success) { VideoData video = result.Data; // Basic info Console.WriteLine($"Title: {video.Title}"); Console.WriteLine($"ID: {video.ID}"); Console.WriteLine($"Duration: {video.Duration} seconds"); Console.WriteLine($"Description: {video.Description}"); // Channel info Console.WriteLine($"Uploader: {video.Uploader}"); Console.WriteLine($"Channel: {video.Channel}"); Console.WriteLine($"Channel URL: {video.ChannelUrl}"); // Statistics Console.WriteLine($"Views: {video.ViewCount}"); Console.WriteLine($"Likes: {video.LikeCount}"); Console.WriteLine($"Upload Date: {video.UploadDate}"); // Available formats Console.WriteLine("\nAvailable formats:"); foreach (FormatData format in video.Formats) { Console.WriteLine($" [{format.FormatId}] {format.Format}"); Console.WriteLine($" Resolution: {format.Width}x{format.Height}"); Console.WriteLine($" Extension: {format.Extension}"); Console.WriteLine($" Video Codec: {format.VideoCodec}"); Console.WriteLine($" Audio Codec: {format.AudioCodec}"); Console.WriteLine($" Filesize: {format.FileSize ?? format.ApproximateFileSize} bytes"); } // Thumbnails if (video.Thumbnails != null) { Console.WriteLine($"\nThumbnails: {video.Thumbnails.Length} available"); } // Subtitles if (video.Subtitles != null) { Console.WriteLine($"\nSubtitles: {string.Join(", ", video.Subtitles.Keys)}"); } } ``` -------------------------------- ### RunUpdate - Update yt-dlp Source: https://context7.com/bluegrams/youtubedlsharp/llms.txt Update the yt-dlp executable to the latest version using the RunUpdate method. This method returns the output from the update process. ```csharp using YoutubeDLSharp; var ytdl = new YoutubeDL(); // Check current version Console.WriteLine($"Current version: {ytdl.Version}"); // Run update string updateOutput = await ytdl.RunUpdate(); Console.WriteLine(updateOutput); // Check version after update Console.WriteLine($"New version: {ytdl.Version}"); ``` -------------------------------- ### Fetch Video Metadata Source: https://github.com/bluegrams/youtubedlsharp/blob/master/README.md Retrieve extensive metadata for a video without downloading it. This includes title, uploader, view count, and available download formats. ```csharp var res = await ytdl.RunVideoDataFetch("https://www.youtube.com/watch?v=_QdPW8JrYzQ"); // get some video information VideoData video = res.Data; string title = video.Title; string uploader = video.Uploader; long? views = video.ViewCount; // all available download formats FormatData[] formats = video.Formats; // ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.