diff --git a/Commands/Modules/VideoUtils.cs b/Commands/Modules/VideoUtils.cs index 482f2b2..bf649ce 100644 --- a/Commands/Modules/VideoUtils.cs +++ b/Commands/Modules/VideoUtils.cs @@ -42,18 +42,12 @@ public async Task TrimVideoAsync( } // Get TimeSpans - TimeSpan trimStart; - TimeSpan trimEnd; + TimeSpan trimStart = TimeSpan.Zero; + TimeSpan trimEnd = TimeSpan.Zero; try { - if (!string.IsNullOrEmpty(trimStartString)) // Avoid invalid format exceptions - trimStart = TimeSpanFromHMS(trimStartString); - else - trimStart = TimeSpan.Zero; - - if (!string.IsNullOrEmpty(trimEndString)) // Avoid invalid format exceptions - trimEnd = TimeSpanFromHMS(trimEndString); - else - trimEnd = TimeSpan.Zero; + // Avoid invalid format exceptions + if (!string.IsNullOrEmpty(trimStartString)) trimStart = TimeSpanFromHMS(trimStartString); + if (!string.IsNullOrEmpty(trimEndString)) trimEnd = TimeSpanFromHMS(trimEndString); } catch (Exception e) { if (e is ArgumentException) { @@ -78,7 +72,7 @@ public async Task TrimVideoAsync( await DownloadVideoAsync(video.Url, videoInputPath); var mediaInfo = await FFProbe.AnalyseAsync(videoInputPath); - CheckTimes(ref trimStart, ref trimEnd, mediaInfo.Duration); + CheckTimes(mediaInfo.Duration, ref trimStart, ref trimEnd); // Check if the temporary directory, where the video is supposed to be exists if (!Directory.Exists("./tmp")) @@ -103,10 +97,10 @@ public async Task TrimVideoAsync( /// Set to 0 if it's greater or equal to the video's /// /// + /// Duration of the video /// Start of the trim /// End of the trim - /// Duration of the video - private static void CheckTimes(ref TimeSpan trimStart, ref TimeSpan trimEnd, TimeSpan duration) + private static void CheckTimes(TimeSpan duration, ref TimeSpan trimStart, ref TimeSpan trimEnd) { // Set trimEnd to duration if smaller or equal to trimStart if (trimEnd <= trimStart) diff --git a/Program.cs b/Program.cs index 20b3a32..a62f0bc 100644 --- a/Program.cs +++ b/Program.cs @@ -45,7 +45,8 @@ private async Task OnReadyAsync() catch { await LogAsync("Program", "Exiting", LogSeverity.Info); - Environment.Exit(1); + // The program cannot continue without the InteractionService, so terminate it. Nothing important should be running at this point. + Environment.Exit(1); // skipcq: CS-W1005 } }