Hello everyone,
I just started using TVheadend a few days ago, and I like it a lot. I'm using version 4.3-1995~g1d0b5e89d~bullseye installed from binary on Debian 11.2 Bullseye. There is just one issue that I can't solve. I'm trying to use this poweroff script: https://tvheadend.org/d/4956-auto-shutdown-and-wakeup-for-scheduled-recordings?r=45174#message-45174 and the script mostly works - the checks for active connections, subscriptions, users, and comskip work, but it can't detect upcoming recordings. Even when recordings are scheduled, it always falls back to the wake at 2 am for no planned recording clause. I've managed to isolate the problem to the following function:
#get start time for next recording
NEXTREC=$(curl --silent --show-error --digest --user "${USER}:${PASS}" --data-urlencode "limit=999" \
"http://${HOST}:9981/api/dvr/entry/grid_upcoming" | \
jq "[ .entries[] | {start_real,status} | \
select(.status!=\"Invalid\") ] | min_by(.start_real) | .start_real")
if [ "$NEXTREC" == "null" ]; then
logit "no planned recording found"
And I believe that these two lines in particular are probably the source of the bug:
jq "[ .entries[] | {start_real,status} | \
select(.status!=\"Invalid\") ] | min_by(.start_real) | .start_real")
There is something in those two lines that's causing the function to always return "null" even when scheduled recordings do exist, and I've tried reading the man pages for jq, but I can't figure it out. Any help you all can give me will be greatly appreciated.
---UPDATE:--- I got a friend on an IRC channel to help me, and he figured out that the problem is not in the jq code at all. Because the jq function worked fine on the file I posted below, but it didn't work when used with curl. Because curl is not downloading any useful data. Maybe there's a bug in the Tvheadend web APIs. I'll try to investigate some more.
Kind regards,
computerworm110