Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chat trim and timestamp format not being applied when enqueuing from chat page #1166

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading