Skip to content

Custom formats

Petter Kraabøl edited this page Apr 6, 2019 · 15 revisions

Adding custom formats is easily done in settings.json, located in ~/.config/tcd/ by default. Create a new entry within "formats": {...} with a unique format name.

Example

Let's say we want to create a new custom format called "kappa". We want to make everyone say Kappa instead of their actual message and save it all to a unique file, categorized by channel names.

We also want absolute timestamps, showing date, time and milliseconds with two digit precision.

"kappa": {
  "comments": {
    "format": "{timestamp[absolute]} {commenter[display_name]} Kappa",
    "timestamp": {
        "absolute": "%x %X.%f"
    },
    "millisecond_precision": 2
  },
  "output": {
    "format": "{id}.txt",
  }
}

We run the Twitch Chat Downloader

tcd -v 211243935 --format kappa --output ~/Desktop/Twitch

# ~/Desktop/Twitch/211243935.txt

12/21/17 00:17:54.67 the_monkaS_grill Kappa
12/21/17 00:17:54.73 プッチパパ Kappa
12/21/17 00:18:01.69 Greeen___ Kappa
12/24/17 23:33:10.65 keshiny Kappa
12/21/17 00:18:02.03 Catbuttholes Kappa

Notice how keshiny's comment was posted days after the other's. They have left this message while watching the VOD. These messages can be ignored with

"comments": {
    "ignore_new_comments": true
}

Variables

{commenter[display_name]} is a formatting syntax, interpreted by Python. Twitch Chat Downloader converts JSON responses form the Twitch API into a Python dictionary. Any value in this dictionary can be referred to using this formatting syntax.

Comments are formatted based on the Twitch API response for comments, whereas output directory and filename is based on video data.

Custom variables

  • {timestamp[absolute]} Date and time for when the comment or video was created.
  • {timestamp[relative]} The time the comment was posted, relative to the beginning of the video.
  • {commenter[badge]} User badges for mods, subs, admins etc. These can be customized in the settings file, in the same way as the irc format.

Notes

  • Absolute timestamps use Python's datetime formatting. See this table for formatting codes.
  • Relative timestamps cannot be formatted, yet.
  • Convert timestamps to other timezones with --timezone. List of timezones.
Clone this wiki locally