Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Remove redundant timestamp option
Browse files Browse the repository at this point in the history
  • Loading branch information
lay295 committed May 27, 2021
1 parent 6be2d3f commit 8ab5aee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
4 changes: 2 additions & 2 deletions TwitchDownloaderCLI/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
5 changes: 1 addition & 4 deletions TwitchDownloaderCLI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
27 changes: 10 additions & 17 deletions TwitchDownloaderCore/ChatDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 8ab5aee

Please sign in to comment.