Here's a quick and dirty script in POSIX shell. It requires cURL, but that is the only requirement. The parameters are as follows:
-
channel - This is the channel you wish to record.
-
start - This is the time to begin recording. Fuzzy options are permitted, such as "5:00PM next Friday", "Oct 2 17:00", or even a specific "10/2/2020 17:00". If your date string is going to have spaces in it, then you need to quote the string. (The order of date versus time does not matter; time should include the colon; times before noon do not require AM, but after noon times must include PM or be in 24-hour notation; if using, it must be
AM/PM
—a
, pm
, or P
will not work, nor will 5:00 PM
with a space.)
-
duration - How long (in minutes) should the recording be.
-
title - This is the title for your recording. (Optional)
-
description - If you are assigning a title, you may also optionally specify a description for the recording. (Optional)
By default, the script will use 127.0.0.1
as the address for your DVR server. If you wish to provide one of your own, set the environment variable CHANNELS
to the IP address of your DVR server. (Alternatively, you may set the CHANNELS
variable at the head of the script, or modify the script's _DVR
variable to point to your DVR server.)
(Note: There is one short-coming with this script: recordings made will not appear in the Library. However, they will be listed in the Recordings page. This is just a bare-bones POC, so feel free to modify to your liking. Thanks to @chDVRuser for their initial work. The only error-checking is to ensure that at least 3 parameters are passed, not to verify they are properly formatted.)
#!/bin/sh
_DVR=${CHANNELS:-127.0.0.1}
if [ -z $3 ]; then
echo "Usage: $0 channel start duration [title [description]]"
exit 0
fi
_CH=$1
_START=$(date -d "$2" +%s)
_DUR=$(("$3" * 60))
_TITLE=${4:-"Manual Recording"}
_DESC=$5
create_job() {
cat << EOF
{
"Name": "${_TITLE}",
"Time": ${_START},
"Duration": ${_DUR},
"Channels": ["${_CH}"],
"Airing": {
"Source": "manual",
"Channel": "${_CH}",
"Time": ${_START},
"Duration": ${_DUR},
"Title": "${_TITLE}",
"Summary": "${_DESC}",
"Image": "https://tmsimg.fancybits.co/assets/p9467679_st_h6_aa.jpg",
"Raw": ""
}
}
EOF
}
curl -XPOST --data-binary "$(create_job)" "http://${_DVR}:8089/dvr/jobs/new"
(Note 2: After the recording has been made, you can access it from your primary storage location. If LOC
is the location of your primary storage location, then recordings are stored as: ${LOC}/TV/${_TITLE}/${_TITLE} $(date -d "@${_START} +%F-%H%M).mpg
, where:
-
LOC
is the storage location referenced earlier
-
_TITLE
is the title you set when creating the recording; if you omitted it, it defaults to Manual Recording
-
_START
is when the recording began as seconds since midnight 1 Jan 1970 (ie, Unix epoch time)
-
$(date ...)
is the time recording started as YYY-MM-DD-HHMM
Since the recordings don't show in the Library, and the Recordings page is not exhaustive/comprehensive, I figured I should include where the files are located and how they're named so they can be found.)