From b823f5c62efec675cb84f254bf53ff3cf61bd3a4 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:36:47 -0400 Subject: [PATCH 1/4] Add settings for chat json compression & chat text timestamp --- TwitchDownloaderWPF/App.config | 6 ++ TwitchDownloaderWPF/PageChatDownload.xaml | 10 +-- TwitchDownloaderWPF/PageChatDownload.xaml.cs | 61 ++++++++++++++++++- .../Properties/Settings.Designer.cs | 24 ++++++++ .../Properties/Settings.settings | 6 ++ 5 files changed, 101 insertions(+), 6 deletions(-) diff --git a/TwitchDownloaderWPF/App.config b/TwitchDownloaderWPF/App.config index fadf8a0c..cdd4342a 100644 --- a/TwitchDownloaderWPF/App.config +++ b/TwitchDownloaderWPF/App.config @@ -235,6 +235,12 @@ 1 + + 0 + + + 0 + \ No newline at end of file diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml b/TwitchDownloaderWPF/PageChatDownload.xaml index 08d5c749..b366bed3 100644 --- a/TwitchDownloaderWPF/PageChatDownload.xaml +++ b/TwitchDownloaderWPF/PageChatDownload.xaml @@ -84,13 +84,13 @@ - - + + - - - + + + diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml.cs b/TwitchDownloaderWPF/PageChatDownload.xaml.cs index 1f295062..e6913302 100644 --- a/TwitchDownloaderWPF/PageChatDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageChatDownload.xaml.cs @@ -55,7 +55,21 @@ private void Page_Initialized(object sender, EventArgs e) { ChatFormat.Text => radioText.IsChecked = true, ChatFormat.Html => radioHTML.IsChecked = true, - _ => radioJson.IsChecked = true + ChatFormat.Json => radioJson.IsChecked = true, + _ => null, + }; + _ = (ChatCompression)Settings.Default.ChatJsonCompression switch + { + ChatCompression.None => radioCompressionNone.IsChecked = true, + ChatCompression.Gzip => radioCompressionGzip.IsChecked = true, + _ => null, + }; + _ = (TimestampFormat)Settings.Default.ChatTextTimestampStyle switch + { + TimestampFormat.Utc => radioTimestampUTC.IsChecked = true, + TimestampFormat.Relative => radioTimestampRelative.IsChecked = true, + TimestampFormat.None => radioTimestampNone.IsChecked = true, + _ => null, }; } @@ -601,5 +615,50 @@ private async void TextUrl_OnKeyDown(object sender, KeyEventArgs e) e.Handled = true; } } + + private void RadioCompressionNone_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatJsonCompression = (int)ChatCompression.None; + Settings.Default.Save(); + } + + private void RadioCompressionGzip_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatJsonCompression = (int)ChatCompression.Gzip; + Settings.Default.Save(); + } + + private void RadioTimestampUTC_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Utc; + Settings.Default.Save(); + } + + private void RadioTimestampRelative_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Relative; + Settings.Default.Save(); + } + + private void RadioTimestampNone_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.None; + Settings.Default.Save(); + } } } \ No newline at end of file diff --git a/TwitchDownloaderWPF/Properties/Settings.Designer.cs b/TwitchDownloaderWPF/Properties/Settings.Designer.cs index 967eff76..55dbb23b 100644 --- a/TwitchDownloaderWPF/Properties/Settings.Designer.cs +++ b/TwitchDownloaderWPF/Properties/Settings.Designer.cs @@ -933,5 +933,29 @@ public int VodTrimMode { this["VodTrimMode"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int ChatJsonCompression { + get { + return ((int)(this["ChatJsonCompression"])); + } + set { + this["ChatJsonCompression"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int ChatTextTimestampStyle { + get { + return ((int)(this["ChatTextTimestampStyle"])); + } + set { + this["ChatTextTimestampStyle"] = value; + } + } } } diff --git a/TwitchDownloaderWPF/Properties/Settings.settings b/TwitchDownloaderWPF/Properties/Settings.settings index 55bedc3f..cf0301d8 100644 --- a/TwitchDownloaderWPF/Properties/Settings.settings +++ b/TwitchDownloaderWPF/Properties/Settings.settings @@ -230,6 +230,12 @@ 1 + + 0 + + + 0 + From fae723051fe417420a63cd6638811eb8d0afb18c Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:36:53 -0400 Subject: [PATCH 2/4] Cleanup --- TwitchDownloaderWPF/PageChatDownload.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml b/TwitchDownloaderWPF/PageChatDownload.xaml index b366bed3..beb9c1e0 100644 --- a/TwitchDownloaderWPF/PageChatDownload.xaml +++ b/TwitchDownloaderWPF/PageChatDownload.xaml @@ -106,7 +106,6 @@ - From 2c446ddd4d442eb3508b81dc0ff49cd5bff03fb9 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:37:14 -0400 Subject: [PATCH 3/4] Extend settings to chat updater page --- TwitchDownloaderWPF/PageChatUpdate.xaml | 10 ++-- TwitchDownloaderWPF/PageChatUpdate.xaml.cs | 61 +++++++++++++++++++++- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/TwitchDownloaderWPF/PageChatUpdate.xaml b/TwitchDownloaderWPF/PageChatUpdate.xaml index 7bf1683d..8aaff93e 100644 --- a/TwitchDownloaderWPF/PageChatUpdate.xaml +++ b/TwitchDownloaderWPF/PageChatUpdate.xaml @@ -84,13 +84,13 @@ - - + + - - - + + + diff --git a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs index 732abef6..b21bedd2 100644 --- a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs +++ b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs @@ -215,7 +215,21 @@ private void Page_Initialized(object sender, EventArgs e) { ChatFormat.Text => radioText.IsChecked = true, ChatFormat.Html => radioHTML.IsChecked = true, - _ => radioJson.IsChecked = true + ChatFormat.Json => radioJson.IsChecked = true, + _ => null, + }; + _ = (ChatCompression)Settings.Default.ChatJsonCompression switch + { + ChatCompression.None => radioCompressionNone.IsChecked = true, + ChatCompression.Gzip => radioCompressionGzip.IsChecked = true, + _ => null, + }; + _ = (TimestampFormat)Settings.Default.ChatTextTimestampStyle switch + { + TimestampFormat.Utc => radioTimestampUTC.IsChecked = true, + TimestampFormat.Relative => radioTimestampRelative.IsChecked = true, + TimestampFormat.None => radioTimestampNone.IsChecked = true, + _ => null, }; } @@ -666,5 +680,50 @@ private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e) }; queueOptions.ShowDialog(); } + + private void RadioCompressionNone_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatJsonCompression = (int)ChatCompression.None; + Settings.Default.Save(); + } + + private void RadioCompressionGzip_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatJsonCompression = (int)ChatCompression.Gzip; + Settings.Default.Save(); + } + + private void RadioTimestampUTC_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Utc; + Settings.Default.Save(); + } + + private void RadioTimestampRelative_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Relative; + Settings.Default.Save(); + } + + private void RadioTimestampNone_OnCheckedChanged(object sender, RoutedEventArgs e) + { + if (!IsInitialized) + return; + + Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.None; + Settings.Default.Save(); + } } } \ No newline at end of file From 60ad60585191d621a81994c5ce27870f5bc3aa82 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:57:36 -0400 Subject: [PATCH 4/4] Remember preferred quality --- TwitchDownloaderWPF/App.config | 3 +++ .../Properties/Settings.Designer.cs | 12 +++++++++++ .../Properties/Settings.settings | 3 +++ TwitchDownloaderWPF/WindowQueueOptions.xaml | 2 +- .../WindowQueueOptions.xaml.cs | 21 +++++++++++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/TwitchDownloaderWPF/App.config b/TwitchDownloaderWPF/App.config index cdd4342a..e16ebc9c 100644 --- a/TwitchDownloaderWPF/App.config +++ b/TwitchDownloaderWPF/App.config @@ -241,6 +241,9 @@ 0 + + + \ No newline at end of file diff --git a/TwitchDownloaderWPF/Properties/Settings.Designer.cs b/TwitchDownloaderWPF/Properties/Settings.Designer.cs index 55dbb23b..0f0c6b35 100644 --- a/TwitchDownloaderWPF/Properties/Settings.Designer.cs +++ b/TwitchDownloaderWPF/Properties/Settings.Designer.cs @@ -957,5 +957,17 @@ public int ChatTextTimestampStyle { this["ChatTextTimestampStyle"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string PreferredQuality { + get { + return ((string)(this["PreferredQuality"])); + } + set { + this["PreferredQuality"] = value; + } + } } } diff --git a/TwitchDownloaderWPF/Properties/Settings.settings b/TwitchDownloaderWPF/Properties/Settings.settings index cf0301d8..15564aee 100644 --- a/TwitchDownloaderWPF/Properties/Settings.settings +++ b/TwitchDownloaderWPF/Properties/Settings.settings @@ -236,6 +236,9 @@ 0 + + + diff --git a/TwitchDownloaderWPF/WindowQueueOptions.xaml b/TwitchDownloaderWPF/WindowQueueOptions.xaml index c7717d4b..154a73eb 100644 --- a/TwitchDownloaderWPF/WindowQueueOptions.xaml +++ b/TwitchDownloaderWPF/WindowQueueOptions.xaml @@ -36,7 +36,7 @@ - + diff --git a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs index b38fd225..e76849bb 100644 --- a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs +++ b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs @@ -98,6 +98,16 @@ public WindowQueueOptions(List dataList) string queueFolder = Settings.Default.QueueFolder; if (Directory.Exists(queueFolder)) textFolder.Text = queueFolder; + + var preferredQuality = Settings.Default.PreferredQuality; + for (var i = 0; i < ComboPreferredQuality.Items.Count; i++) + { + if (ComboPreferredQuality.Items[i] is ComboBoxItem { Content: string quality } && quality == preferredQuality) + { + ComboPreferredQuality.SelectedIndex = i; + break; + } + } } private FileInfo HandleFileCollisionCallback(FileInfo fileInfo) @@ -721,5 +731,16 @@ private void CheckVideo_OnChecked(object sender, RoutedEventArgs e) catch { /* Ignored */ } } } + + private void ComboPreferredQuality_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!IsInitialized) + return; + + if (ComboPreferredQuality.SelectedItem is ComboBoxItem { Content: string preferredQuality }) + { + Settings.Default.PreferredQuality = preferredQuality; + } + } } } \ No newline at end of file