From 003b649fc7f00024713c4018c3d2523c71a9cfe5 Mon Sep 17 00:00:00 2001 From: bdovaz Date: Sun, 1 Nov 2026 15:51:56 +0100 Subject: [PATCH] Add missing arguments to GetMetadataInternalAsync --- src/Ytdlp.NET/Ytdlp.cs | 63 +++++++++++++++++------------- src/Ytdlp.NET/Ytdlp/Ytdlp.Probe.cs | 5 +++ 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/Ytdlp.NET/Ytdlp.cs b/src/Ytdlp.NET/Ytdlp.cs index 6368511..6a33ba0 100644 --- a/src/Ytdlp.NET/Ytdlp.cs +++ b/src/Ytdlp.NET/Ytdlp.cs @@ -290,17 +290,10 @@ public Ytdlp AddOption(string key, string value) /// /// /// - private List BuildArguments(string url) + private List BuildConnectionArguments() { var args = new List(); - bool usingAbsoluteOutput = !string.IsNullOrWhiteSpace(_outputFolder); - - if (usingAbsoluteOutput && !string.IsNullOrWhiteSpace(_tempFolder)) - { - _logger.Log(LogType.Debug, "Temp folder ignored because absolute output template is used."); - } - // Authentication if (_auth is not null) { @@ -324,6 +317,40 @@ private List BuildArguments(string url) args.Add("-"); // tells yt-dlp to read from stdin } + // Options + if (_options.Length > 0) + { + foreach (var kv in _options) + { + args.Add(kv.Key); + if (kv.Value != null) + args.Add(kv.Value); + } + } + + // Special single-value options + if (_cookiesFile is not null) { args.Add("--cookies"); args.Add(_cookiesFile); } + if (_cookiesFromBrowser is not null) { args.Add("--cookies-from-browser"); args.Add(_cookiesFromBrowser); } + if (_proxy is not null) { args.Add("--proxy"); args.Add(_proxy); } + if (_ffmpegLocation is not null) { args.Add("--ffmpeg-location"); args.Add(_ffmpegLocation); } + if (_sponsorblockMark is not null) { args.Add("--sponsorblock-mark"); args.Add(_sponsorblockMark); } + if (_sponsorblockRemove is not null) { args.Add("--sponsorblock-remove"); args.Add(_sponsorblockRemove); } + if (_sponsorblockChapterTitle is not null) { args.Add("--sponsorblock-chapter-title"); args.Add(_sponsorblockChapterTitle); } + + return args; + } + + private List BuildArguments(string url) + { + var args = BuildConnectionArguments(); + + bool usingAbsoluteOutput = !string.IsNullOrWhiteSpace(_outputFolder); + + if (usingAbsoluteOutput && !string.IsNullOrWhiteSpace(_tempFolder)) + { + _logger.Log(LogType.Debug, "Temp folder ignored because absolute output template is used."); + } + // temp folder if (!usingAbsoluteOutput && !string.IsNullOrWhiteSpace(_tempFolder)) { @@ -372,26 +399,6 @@ private List BuildArguments(string url) if (_flags.Length > 0) args.AddRange(_flags); - // Options - if (_options.Length > 0) - { - foreach (var kv in _options) - { - args.Add(kv.Key); - if (kv.Value != null) - args.Add(kv.Value); - } - } - - // Special single-value options - if (_cookiesFile is not null) { args.Add("--cookies"); args.Add(_cookiesFile); } - if (_cookiesFromBrowser is not null) { args.Add("--cookies-from-browser"); args.Add(_cookiesFromBrowser); } - if (_proxy is not null) { args.Add("--proxy"); args.Add(_proxy); } - if (_ffmpegLocation is not null) { args.Add("--ffmpeg-location"); args.Add(_ffmpegLocation); } - if (_sponsorblockMark is not null) { args.Add("--sponsorblock-mark"); args.Add(_sponsorblockMark); } - if (_sponsorblockRemove is not null) { args.Add("--sponsorblock-remove"); args.Add(_sponsorblockRemove); } - if (_sponsorblockChapterTitle is not null) { args.Add("--sponsorblock-chapter-title"); args.Add(_sponsorblockChapterTitle); } - // URL last args.Add(url); diff --git a/src/Ytdlp.NET/Ytdlp/Ytdlp.Probe.cs b/src/Ytdlp.NET/Ytdlp/Ytdlp.Probe.cs index 040d4b8..c061b7c 100644 --- a/src/Ytdlp.NET/Ytdlp/Ytdlp.Probe.cs +++ b/src/Ytdlp.NET/Ytdlp/Ytdlp.Probe.cs @@ -431,6 +431,8 @@ public async Task> GetSubtitlesAsync(string url, Cancellatio { var result = await CreateRunner().ExecuteAsync( arguments, + auth: _auth, + adobePass: _adobePass, onLineReceived: null, ct: ct, tuneProcess: tuneProcess, @@ -458,7 +460,10 @@ public async Task> GetSubtitlesAsync(string url, Cancellatio if (string.IsNullOrWhiteSpace(url)) throw new ArgumentException("URL cannot be empty.", nameof(url)); + var connectionArguments = string.Join(" ", BuildConnectionArguments().Select(EscapeArgument)); + var arguments = + (connectionArguments.Length > 0 ? connectionArguments + " " : string.Empty) + "--dump-single-json " + "--simulate " + "--skip-download " +