YoutubeDLSharp icon indicating copy to clipboard operation
YoutubeDLSharp copied to clipboard

Problem with OutputFolder settings

Open meakcega opened this issue 1 year ago • 1 comments

Hello, I have problem with OutputFolder settings:

YoutubeDL ytdl = new YoutubeDL();
ytdl.OutputFolder = @"C:\Output";

OptionSet optionSet= new OptionSet();
string temp = @"C:\Temp";
optionSet.Paths = $"temp:{temp}";
optionSet.Output = "%(title)s.%(ext)s";

await ytdl.RunVideoDownload(ytVideo.Url, progress: progress, overrideOptions: optionSet);

When I run code, the temp files were saved correctly in "C:\Temp". But after finishing download, the video files were not saved to "C:\Output". Instead they were saved to the folder that contains "yt-dlp.exe" file.

When I removed variable "optionSet". It works correctly , all video files were saved to "C:\Output":

YoutubeDL ytdl = new YoutubeDL();

ytdl.OutputFolder = @"C:\Output";
ytdl.OutputFileTemplate = "%(title)s.%(ext)s";

await ytdl.RunVideoDownload(ytVideo.Url, progress: progress);

How can I setup "OutputFolder" correctly? Please advise me. And I want to add a folder to save subtitle files. How can I do that?

meakcega avatar Sep 11 '24 13:09 meakcega

I don't have the definitive answer though I've been experimenting with this a lot lately. As far as I can tell you need to set the OutputFolder (as you have) and unfortunately also use the full path in the optionSet.Output. In the example above you would concatenate your temp variable with the template you are sing for optionSet.Output. If there is some way to avoid the duplicate definition I don't know but this works for me.

tleylan avatar Oct 06 '24 18:10 tleylan

The issue here is that YoutubeDL's OutputFolder and OutputFileTemplate doesn't work well with setting Paths in OptionSet as the former properties modify yt-dlp's --output option. So the recommended way is to use either the former XOR the latter, ie:

option 1: use OutputFolder

YoutubeDL ytdl = new YoutubeDL();
ytdl.OutputFolder = @"C:\Output";
ytdl.OutputFileTemplate = "%(title)s.%(ext)s";

option 2: use Paths and unset OutputFolder

YoutubeDL ytdl = new YoutubeDL();
ytdl.OutputFolder = "";  // unset here
var optionsSet = new OptionSet()
{
    Paths = new[]
    {
        "temp:C:\Temp",
        "home:C:\Output"
    }
};

Closing this issue, please re-open if anything is unclear.

alxnull avatar Jan 04 '26 16:01 alxnull