Files
Harmony/HarmonyWinUI/Models/YTDLP.cs
T

44 lines
803 B
C#

using System;
using System.IO;
namespace HarmonyWinUI.Models
{
class YTDLP
{
private String binPath = string.Empty;
public YTDLP()
{
this.binPath = this.findBinnary();
System.Diagnostics.Debug.WriteLine("binPath = " + this.binPath);
if (this.binPath.Equals(string.Empty))
{
throw new Exception("Binnary for YT-DLP not found.");
}
}
private String findBinnary()
{
DirectoryInfo? currentDirectory = new DirectoryInfo(AppContext.BaseDirectory);
while (currentDirectory != null)
{
string candidatePath = Path.Combine(
currentDirectory.FullName,
"vendor",
"yt-dlp.exe"
);
if (File.Exists(candidatePath))
{
return candidatePath;
}
currentDirectory = currentDirectory.Parent;
}
return string.Empty;
}
}
}