From 94971a4f3e953ce1d0016e229202f41807990928 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Sat, 3 Feb 2024 15:26:16 -0500 Subject: [PATCH] More robust file extension assumption for CLI videodownload --- TwitchDownloaderCLI/Modes/DownloadVideo.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/TwitchDownloaderCLI/Modes/DownloadVideo.cs b/TwitchDownloaderCLI/Modes/DownloadVideo.cs index b7a1574f..f2edcf07 100644 --- a/TwitchDownloaderCLI/Modes/DownloadVideo.cs +++ b/TwitchDownloaderCLI/Modes/DownloadVideo.cs @@ -32,7 +32,7 @@ private static VideoDownloadOptions GetDownloadOptions(VideoDownloadArgs inputOp } var vodIdMatch = TwitchRegex.MatchVideoId(inputOptions.Id); - if (vodIdMatch is not { Success: true}) + if (vodIdMatch is not { Success: true }) { Console.WriteLine("[ERROR] - Unable to parse Vod ID/URL."); Environment.Exit(1); @@ -40,10 +40,12 @@ private static VideoDownloadOptions GetDownloadOptions(VideoDownloadArgs inputOp if (!Path.HasExtension(inputOptions.OutputFile) && inputOptions.Quality is { Length: > 0 }) { - if (char.IsDigit(inputOptions.Quality[0])) - inputOptions.OutputFile += ".mp4"; - else if (char.ToLower(inputOptions.Quality[0]) is 'a') + if (inputOptions.Quality.Contains("audio", StringComparison.OrdinalIgnoreCase)) inputOptions.OutputFile += ".m4a"; + else if (char.IsDigit(inputOptions.Quality[0]) + || inputOptions.Quality.Contains("source", StringComparison.OrdinalIgnoreCase) + || inputOptions.Quality.Contains("chunked", StringComparison.OrdinalIgnoreCase)) + inputOptions.OutputFile += ".mp4"; } VideoDownloadOptions downloadOptions = new() @@ -70,4 +72,4 @@ private static VideoDownloadOptions GetDownloadOptions(VideoDownloadArgs inputOp return downloadOptions; } } -} +} \ No newline at end of file