Skip to content

Commit

Permalink
Fix chat trim and timestamp format not being applied when enqueuing f…
Browse files Browse the repository at this point in the history
…rom chat page (#1166)

* Fix chat trimming and timestamp format not being applied when enqueuing

* Remove unused property

* Fix clip chats
  • Loading branch information
ScrubN authored Jul 29, 2024
1 parent 4c65eb8 commit e3dcb20
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 32 deletions.
2 changes: 0 additions & 2 deletions TwitchDownloaderCore/TwitchObjects/ChatRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ public class LegacyEmbedChatBadge
{
public string name { get; set; }
public Dictionary<string, byte[]> versions { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, string> urls { get; set; }
}

[DebuggerDisplay("{prefix}")]
Expand Down
55 changes: 26 additions & 29 deletions TwitchDownloaderWPF/PageChatDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e3dcb20

Please sign in to comment.