Skip to main content

Variable scheduling

Custom variables

Custom variables are key to using variable scheduling properly. We highly advice reading up on these, but at its core these are variables you can create yourself using either a static replacement or a script.

Using variables

Using variables can be done simply by setting an automatic push to use variables to schedule a recording.

Picture of setting a variables to start recordings

Here you can use variables to create your own recording logic. Any custom variable you might have create can be used and compared to either a given value or another variable.

Picture of using variables during a variable recording schedule

Variables can be used and compared through various means:

symbolMeaning
is truePush will start/stop if the variable has a value
is falsePush will start/stop if the variable has no value
==Push will start/stop if the variable is a perfect match
!=Push will start/stop if the variable is not a perfect match
> (numerical)Push will start/stop if the variable is considered higher on a numerical scale
>= (numerical)Push will start/stop if the variable is considered equal or higher on a numerical scale
< (numerical)Push will start/stop if the variable is considered lower on a numerical scale
<= (numerical)Push will start/stop if the variable is considered equal or lower on a numerical scale
> (lexical)Push will start/stop if the variable is considered higher on a lexical scale
>= (lexical)Push will start/stop if the variable is considered equal or higher on a lexical scale
< (lexical)Push will start/stop if the variable is considered lower on a lexical scale
<= (lexical)Push will start/stop if the variable is considered equal or lower on a lexical scale

Picture of the methods you can use to compare variables

Examples

Using date to create a weekly recording on a Tuesday at 15:00 to 16:00

For this example 3 variables are necessary.

now : A variable running date +%s start : A variable running date --date=tuesday15:00 +%s stop : A variable running date --date=tuesday16:00 +%s

Picture of the variables in place

How this works: the variables call upon date, which will return the server time in UNIX time. The date command that checks Tuesdays at specific times will update to the next Tuesday whenever Tuesday has passed. Thus this will be valid whenever it is Tuesday between 15:00 and 16:00.

Using is true for recording

For this example only 1 variable is necessary.

reclive : This variable should check a database field. As an example a SQLite check for the field "record_on" and a field containing the "stream_name" would be present too would be something like.

#!/bin/bash

DB=/path/to/database.sqlite

#using direct output of sqlite3 here, it'll list the selection seperated by |.


STREAM=`echo "SELECT record_on from database where stream_name == '$1' | sqlite3 "$DB"`
echo -n $STREAM


Now this example uses bash sqlite3 and assumes there is a database with the fields "record_on" and "stream_name". Using this script would be a variable with the command /path/to/script streamname.

Picture of istrue isfalse example

Whenever the database updates the field for "record_on" to 1 automatic recordings will take place, if it's set back to 0 or empty recordings will stop.

Now an obvious downside to this set up is that you will need to create a variable per stream you wish to record. The upside is that this is easier to understand if using the API directly and triggers isn't your thing.