From e3dcb201f291ef0584fd44089026f632d1573b6d Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:32:16 -0400 Subject: [PATCH] Fix chat trim and timestamp format not being applied when enqueuing from chat page (#1166) * Fix chat trimming and timestamp format not being applied when enqueuing * Remove unused property * Fix clip chats --- .../TwitchObjects/ChatRoot.cs | 2 - TwitchDownloaderWPF/PageChatDownload.xaml.cs | 55 +++++++++---------- .../WindowQueueOptions.xaml.cs | 1 - 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/TwitchDownloaderCore/TwitchObjects/ChatRoot.cs b/TwitchDownloaderCore/TwitchObjects/ChatRoot.cs index 03d650a2..c0604a1e 100644 --- a/TwitchDownloaderCore/TwitchObjects/ChatRoot.cs +++ b/TwitchDownloaderCore/TwitchObjects/ChatRoot.cs @@ -242,8 +242,6 @@ public class LegacyEmbedChatBadge { public string name { get; set; } public Dictionary versions { get; set; } - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public Dictionary urls { get; set; } } [DebuggerDisplay("{prefix}")] diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml.cs b/TwitchDownloaderWPF/PageChatDownload.xaml.cs index 9fcf5861..5820d9bf 100644 --- a/TwitchDownloaderWPF/PageChatDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageChatDownload.xaml.cs @@ -268,6 +268,32 @@ public ChatDownloadOptions GetOptions(string filename) else if (radioCompressionGzip.IsChecked == true) options.Compression = ChatCompression.Gzip; + // TODO: Enable trimming clip chats + if (downloadType is DownloadType.Video) + { + if (CheckTrimStart.IsChecked == true) + { + options.TrimBeginning = true; + TimeSpan start = new TimeSpan((int)numStartHour.Value, (int)numStartMinute.Value, (int)numStartSecond.Value); + options.TrimBeginningTime = (int)start.TotalSeconds; + } + + if (CheckTrimEnd.IsChecked == true) + { + options.TrimEnding = true; + TimeSpan end = new TimeSpan((int)numEndHour.Value, (int)numEndMinute.Value, (int)numEndSecond.Value); + options.TrimEndingTime = (int)end.TotalSeconds; + } + } + + if (radioTimestampUTC.IsChecked == true) + options.TimeFormat = TimestampFormat.Utc; + else if (radioTimestampRelative.IsChecked == true) + options.TimeFormat = TimestampFormat.Relative; + else if (radioTimestampNone.IsChecked == true) + options.TimeFormat = TimestampFormat.None; + + options.Id = downloadId; options.EmbedData = checkEmbed.IsChecked.GetValueOrDefault(); options.BttvEmotes = checkBttvEmbed.IsChecked.GetValueOrDefault(); options.FfzEmotes = checkFfzEmbed.IsChecked.GetValueOrDefault(); @@ -501,35 +527,6 @@ private async void SplitBtnDownload_Click(object sender, RoutedEventArgs e) try { ChatDownloadOptions downloadOptions = GetOptions(saveFileDialog.FileName); - if (downloadType == DownloadType.Video) - { - if (CheckTrimStart.IsChecked == true) - { - downloadOptions.TrimBeginning = true; - TimeSpan start = new TimeSpan((int)numStartHour.Value, (int)numStartMinute.Value, (int)numStartSecond.Value); - downloadOptions.TrimBeginningTime = (int)start.TotalSeconds; - } - - if (CheckTrimEnd.IsChecked == true) - { - downloadOptions.TrimEnding = true; - TimeSpan end = new TimeSpan((int)numEndHour.Value, (int)numEndMinute.Value, (int)numEndSecond.Value); - downloadOptions.TrimEndingTime = (int)end.TotalSeconds; - } - - downloadOptions.Id = downloadId; - } - else - { - downloadOptions.Id = downloadId; - } - - if (radioTimestampUTC.IsChecked == true) - downloadOptions.TimeFormat = TimestampFormat.Utc; - else if (radioTimestampRelative.IsChecked == true) - downloadOptions.TimeFormat = TimestampFormat.Relative; - else if (radioTimestampNone.IsChecked == true) - downloadOptions.TimeFormat = TimestampFormat.None; var downloadProgress = new WpfTaskProgress((LogLevel)Settings.Default.LogLevels, SetPercent, SetStatus, AppendLog); var currentDownload = new ChatDownloader(downloadOptions, downloadProgress); diff --git a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs index a65fdb5a..561c4308 100644 --- a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs +++ b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs @@ -344,7 +344,6 @@ private void btnQueue_Click(object sender, RoutedEventArgs e) } ChatDownloadOptions chatOptions = MainWindow.pageChatDownload.GetOptions(null); - chatOptions.Id = chatDownloadPage.downloadId; chatOptions.Filename = Path.Combine(folderPath, FilenameService.GetFilename(Settings.Default.TemplateChat, chatDownloadPage.textTitle.Text, chatOptions.Id,chatDownloadPage.currentVideoTime, chatDownloadPage.textStreamer.Text, chatOptions.TrimBeginning ? TimeSpan.FromSeconds(chatOptions.TrimBeginningTime) : TimeSpan.Zero, chatOptions.TrimEnding ? TimeSpan.FromSeconds(chatOptions.TrimEndingTime) : chatDownloadPage.vodLength,