Skip to content

Custom save expressions

Morten Møller edited this page Oct 17, 2022 · 3 revisions

Custom save expressions

By creating your own expression, you can essentially save each clip exactly as you want. If you want to store clips by year, then month, then day, you can easily do that using custom save expressions.

Almost anything related to each clip is easy to implement by using variable names.

Example

If you want your clips to be saved as:

broadcaster/
├─ year/
│  ├─ month/
│  │  ├─ day/
│  │  │  ├─ clipname.mp4

your expression should look like this:

/{broadcaster_name}/{yyyy}/{MM}/{dd}/{id}.mp4

{broadcaster_name} is the name of the broadcaster (for example Sodapoppin), {yyyy} is the year the clip was made, {MM} is the month, {dd} is the day of the month, and {id} is the automatically generated ID Twitch gives each clip (also known as slug).

Requirements

  1. Your expressions MUST end with .mp4 or .MP4. This is simply a limitation set by me, and it also makes my life a lot easier. Each clip from youtube-dl is saved as .mp4 by default either way, so might as well do that
  2. A few illegal (operating system dependent) characters have been introduced. As long as you stick to your A-Z, your 0-9, your regular directory and file names.. you should be fine. I'm removing illegal characters anyway, so go ahead and try to break it (and then make a pull request with a fix please)
  3. An equal amount of curly brackets. I use curly brackets for my expressions, so you have to deal with that (also who uses curly brackets in their directory or file names??)

Reference table

Clip details

Expression Value Example value
id ID/Slug of the clip TrappedAmericanBoarAMPTropPunch
broadcaster_name Name of the broadcaster Sodapoppin
broadcaster_id ID of the broadcaster 26301881
game_id ID of the game being played 18122
title Title of the clip OMEGALUL
viewcount The clip's view count 125129
uploader Who created the clip mortenmoulder

Dates

Expression Value Example value
yyyy Year 2021
MMMM Full month name June
MMM Abbreviated month name Jun
MM Month number with leading zero 09
M Month number without leading zero 9
dddd Full day name Wednesday
ddd Abbreviated day name Wed
dd Day number with leading zero 05
d Day number without leading zero 5
HH 24-hour clock hour with leading zero 08
H 24-hour clock without leading zero 8
mm Minutes with leading zero 02
m Minutes without leading zero 2
ss Seconds with leading zero 03
s Seconds without leading zero 3
tt AM / PM AM