From 8ab5aeedd3b14e22797578a4e21c055da4ff4f1d Mon Sep 17 00:00:00 2001 From: lay295 Date: Thu, 27 May 2021 04:13:33 -0400 Subject: [PATCH] Remove redundant timestamp option --- TwitchDownloaderCLI/Options.cs | 4 ++-- TwitchDownloaderCLI/README.md | 5 +---- TwitchDownloaderCore/ChatDownloader.cs | 27 ++++++++++---------------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/TwitchDownloaderCLI/Options.cs b/TwitchDownloaderCLI/Options.cs index a66fdf37..1747996f 100644 --- a/TwitchDownloaderCLI/Options.cs +++ b/TwitchDownloaderCLI/Options.cs @@ -34,9 +34,9 @@ class Options public int DownloadThreads { get; set; } [Option("oauth", HelpText = "OAuth to be passed when downloading a VOD.")] public string Oauth { get; set; } - [Option("timestamp", HelpText = "Enable timestamp for chat download in .txt format or chat render.")] + [Option("timestamp", HelpText = "Enable timestamp in chat render.")] public bool Timestamp { get; set; } - [Option("timestamp-format", HelpText = "Sets the timestamp format for .txt chat logs. Valid values are Utc, Relative, and None")] + [Option("timestamp-format", HelpText = "Sets the timestamp format for .txt chat logs. Valid values are Utc, Relative, and None", Default = TimestampFormat.None)] public TimestampFormat TimeFormat { get; set; } [Option("embed-emotes", HelpText = "Embed emotes into chat download.")] public bool EmbedEmotes { get; set; } diff --git a/TwitchDownloaderCLI/README.md b/TwitchDownloaderCLI/README.md index fb9320dd..91154171 100644 --- a/TwitchDownloaderCLI/README.md +++ b/TwitchDownloaderCLI/README.md @@ -61,9 +61,6 @@ Time in seconds to crop beginning. For example if I wanted a 10 second stream bu **-e/-\-ending** Time in seconds to crop ending. For example if I wanted a 10 second stream but only wanted the first 4 seconds of it I would use -e 4 remove the last 6 seconds of it. -**-\-timestamp** -If downloading to a text file, will add timestamps before each message. - **-\-timestamp-format** Sets the timestamp format for .txt chat logs. Valid values are Utc, Relative, and None. @@ -141,7 +138,7 @@ Download a Clip TwitchDownloaderCLI -m ClipDownload --id NurturingCalmHamburgerVoHiYo -o clip.mp4 Download a Chat (plain text with timestamps) - TwitchDownloaderCLI -m ChatDownload --id 612942303 --timestamp -o chat.txt + TwitchDownloaderCLI -m ChatDownload --id 612942303 --timestamp-format Relative -o chat.txt Download a Chat (JSON with embeded emotes) TwitchDownloaderCLI -m ChatDownload --id 612942303 --embed-emotes -o chat.json diff --git a/TwitchDownloaderCore/ChatDownloader.cs b/TwitchDownloaderCore/ChatDownloader.cs index 1d5feb26..886dbe50 100644 --- a/TwitchDownloaderCore/ChatDownloader.cs +++ b/TwitchDownloaderCore/ChatDownloader.cs @@ -160,25 +160,18 @@ await Task.Run(() => { { string username = comment.commenter.display_name; string message = comment.message.body; - if (downloadOptions.Timestamp) + if (downloadOptions.TimeFormat == TimestampFormat.Utc) { - if (downloadOptions.TimeFormat == TimestampFormat.Utc) - { - string timestamp = comment.created_at.ToString("u").Replace("Z", " UTC"); - sw.WriteLine(String.Format("[{0}] {1}: {2}", timestamp, username, message)); - } - else if (downloadOptions.TimeFormat == TimestampFormat.Relative) - { - TimeSpan time = new TimeSpan(0, 0, (int)comment.content_offset_seconds); - string timestamp = time.ToString(@"h\:mm\:ss"); - sw.WriteLine(String.Format("[{0}] {1}: {2}", timestamp, username, message)); - } - else if (downloadOptions.TimeFormat == TimestampFormat.None) - { - sw.WriteLine(String.Format("{0}: {1}", username, message)); - } + string timestamp = comment.created_at.ToString("u").Replace("Z", " UTC"); + sw.WriteLine(String.Format("[{0}] {1}: {2}", timestamp, username, message)); } - else + else if (downloadOptions.TimeFormat == TimestampFormat.Relative) + { + TimeSpan time = new TimeSpan(0, 0, (int)comment.content_offset_seconds); + string timestamp = time.ToString(@"h\:mm\:ss"); + sw.WriteLine(String.Format("[{0}] {1}: {2}", timestamp, username, message)); + } + else if (downloadOptions.TimeFormat == TimestampFormat.None) { sw.WriteLine(String.Format("{0}: {1}", username, message)); }