Skip to content

YoutubeDL version value is not cross-platform compatible #61

@kitsumed

Description

@kitsumed

The version key in the YoutubeDL class is not working as expected on Linux systems due to its use of FileVersionInfo.GetVersionInfo, which can have undesired behavior, like returning a empty string. A stable work-around would be to get the version output from the yt-dlp binary itself by running it with the --version argument when first creating the object and then save the value to a private version key that can later be read using the public version key as a GET; only.

As a workaround for others users, you can get the current yt-dlp version using this code (not async)

// Create a temporary yt-dlp proc
YoutubeDLProcess temporaryYTDLPProc = new YoutubeDLProcess("yt-dlp path here");
// Create a event handler to listen to the proc outputs
EventHandler<DataReceivedEventArgs> outputHandler = (o, e) =>
{
// e.Data is the proc output, when running --version arg, the first and only output should be in yyyy.MM.dd format.
};
// Attach the event handler to the proc
temporaryYTDLPProc.OutputReceived += outputHandler;
// Run the proc with the --version argument and wait for proc exit
temporaryYTDLPProc.RunAsync(null, new OptionSet { Version = true}).Wait();
// Detach the event handler to allow the GC to free memory
temporaryYTDLPProc.OutputReceived -= outputHandler;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions