diff --git a/YouTubeDlpGui/ViewModels/MainWindowViewModel.cs b/YouTubeDlpGui/ViewModels/MainWindowViewModel.cs index 4dca3c3..8104c62 100644 --- a/YouTubeDlpGui/ViewModels/MainWindowViewModel.cs +++ b/YouTubeDlpGui/ViewModels/MainWindowViewModel.cs @@ -42,7 +42,10 @@ public void OnDownloadButtonClicked() var ytDlPDownloadUrl = GetYtDlpDownloadUrl(); instance.YtDlPath = GetYtDlpPath(); Dispatcher.UIThread.InvokeAsync(() => instance.StatusLabel.Text = "Downloading YT-Dlp..."); - DownloadFile(ytDlPDownloadUrl, instance.YtDlPath); + if(Environment.OSVersion.Platform == PlatformID.Win32NT) + instance.YtDlPath = DownloadYtDlpWindows(ytDlPDownloadUrl, Path.Combine(Path.GetTempPath(), "yt-dlp.zip")); + else + DownloadFile(ytDlPDownloadUrl, instance.YtDlPath); if (Environment.OSVersion.Platform.Equals(PlatformID.Unix) || Environment.OSVersion.Platform.Equals(PlatformID.MacOSX)) { @@ -72,7 +75,8 @@ public void OnDownloadButtonClicked() if (Environment.OSVersion.Platform.Equals(PlatformID.Win32NT) || Environment.OSVersion.Platform.Equals(PlatformID.MacOSX)) { - ZipFile.ExtractToDirectory(path, ffmpegFolderPath); + ZipFile.ExtractToDirectory(path, ffmpegFolderPath, true); + ffmpegFolderPath = Directory.GetDirectories(Directory.GetDirectories(ffmpegFolderPath).First()).First(); } else { @@ -84,6 +88,7 @@ public void OnDownloadButtonClicked() var ffmpegPath = Path.Combine(ffmpegFolderPath, Environment.OSVersion.Platform.Equals(PlatformID.Win32NT) ? "ffmpeg.exe" : "ffmpeg"); if (!File.Exists(ffmpegPath)) + { Dispatcher.UIThread.InvokeAsync(() => { instance.DownloadButton.IsEnabled = true; @@ -94,6 +99,8 @@ public void OnDownloadButtonClicked() instance.VideoDownloadPathButton.IsEnabled = true; instance.ErrorTextBlock.Text = "Failed to download and extract ffmpeg"; }); + return; + } var format = "mp4"; var formattingMethod = "remux"; @@ -159,7 +166,7 @@ public void OnDownloadButtonClicked() }); thread.Start(); - instance.DownloadButton.Content = "Starting..."; + instance.StatusLabel.Text = "Starting..."; instance.DownloadButton.IsEnabled = false; instance.VideoDownloadPathTextBox.IsEnabled = false; instance.UrlTextBox.IsEnabled = false; @@ -168,6 +175,14 @@ public void OnDownloadButtonClicked() instance.VideoDownloadPathButton.IsEnabled = false; } + private string DownloadYtDlpWindows(string ytDlPDownloadUrl, string path) + { + DownloadFile(ytDlPDownloadUrl, path); + var folderPath = Path.Combine(Path.GetTempPath(), "yt-dlp"); + ZipFile.ExtractToDirectory(path, folderPath, true); + return Path.Combine( folderPath, "yt-dlp.exe"); + } + private void ExtractTarArchive(string path, string ffmpegFolderPath) { var process = new Process @@ -191,7 +206,7 @@ private string GetYtDlpDownloadUrl() { PlatformID.Unix => "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux", PlatformID.MacOSX => "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos", - PlatformID.Win32NT => "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_min.exe", + PlatformID.Win32NT => "https://github.com/yt-dlp/yt-dlp/releases/download/2022.07.18/yt-dlp_win.zip", _ => throw new PlatformNotSupportedException("This platform is not supported!") }; } @@ -284,7 +299,7 @@ public string GetFfmpegDownloadUrl() { PlatformID.Unix => "https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz", PlatformID.MacOSX => "https://ffmpeg.zeranoe.com/builds/macos64/static/ffmpeg-latest-macos64-static.zip", - PlatformID.Win32NT => "https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip", + PlatformID.Win32NT => "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip", _ => throw new PlatformNotSupportedException("This platform is not supported!") }; }