Trouble fetching upcoming recordings.
CanOfColliders opened this issue · 4 comments
I'm having some issues with autosuspend figuring out the next activity. Noticed that the machine was still running and checked the logs which gave me lots of:
Jan 17 17:10:02 ada autosuspend[3082]: Fetched next 0 upcoming recordings from Tvheadend
Jan 17 17:10:02 ada autosuspend[3084]: Next activity starts in -24744490 minutes, auto suspend terminated
It's not empty, there are several recordings scheduled, the next recording in tvheadend would be on saturday.
It seems it can't read them anymore somehow, and basically schedules "next" as -unix epoch time (1970).
I updated it about a week ago, because i had some issues where it not always came up at the correct time (scheduled the wrong recording as the next one sometimes).
However, after the update it seemed to work fine again (and checking the logs, it noticed several recordings over the week and scheduled/shutdown correctly between them).
Until yesterday, now it's been doing this.
Just checked the user settings in tvheadend and the /etc/autosuspend config. Also permission, seems fine.
Any idea on what could cause this would be appreciated.
I updated it about a week ago, because i had some issues where it not always came up at the correct time (scheduled the wrong recording as the next one sometimes).
Yes, this could have happened before commit e98ab65 when more than 50 recordings were scheduled.
Your current problem sounds like the script doesn't get any recordings from Tvheadend. Please try the script test-autosuspend-function.sh with argument FindNextActivity
:
$ ./test-autosuspend-function.sh FindNextActivity
This should print the next activity, like
AutoSuspend: Fetched next 5 upcoming recordings from Tvheadend
AutoSuspend: Ignoring past activity at Di 17. Jan 19:19:30 CET 2017: Foo from Tvheadend schedule
AutoSuspend: Next activity at Di 17. Jan 20:09:30 CET 2017: Bar
1484680170
If it states Fetched next 0 upcoming recordings
, either the curl request or the jq call fails.
You could then check the curl statement manually by calling
curl -s --user "$TVHEADEND_USER:$TVHEADEND_PASSWORD" "http://ada:9981/api/dvr/entry/grid_upcoming?sort=start_real&dir=ASC&limit=5" >response.json
The file response.json
should contain the JSON response from Tvheadend.
Feel free to attach the JSON file here, so that I can check if the parsing that is done by jq
works as expected.
Yes, this could have happened before commit e98ab65 when more than 50 recordings were scheduled.
Ah that's what it was, it's a relatively new setup for me (switched to tvheadend in november) and i did add an awful lot of recordings to really test the system (might have been easily 50+).
Thanks for the help!
So i gave it a shot
$ ./test-autosuspend-function.sh FindNextActivity
jq: error (at <stdin>:1): Cannot iterate over null (null)
AutoSuspend: Fetched next 0 upcoming recordings from Tvheadend
Afterwards curl, which resulted in an 401 UNAUTHORIZED, checking on it, it was because
$TVHEADEND_USER:$TVHEADEND_PASSWORD
are not set. Are they supposed to be populated after running the test script? Because they both were empty.
Anyway, after putting the username:password in the curl command manually, i attached the resulting JSON (before deleting timers, the one that caused the issue).
That first recording seems to be the issue.
I went ahead an deleted the first one in tvheadend ("Die Tagesschau vor 25 Jahren"), jq still errors out but it does find the next one now.
$ ./test-autosuspend-function.sh FindNextActivity
jq: error (at <stdin>:1): Cannot iterate over null (null)
AutoSuspend: Fetched next 1 upcoming recordings from Tvheadend
AutoSuspend: Next activity at So 22. Jan 16:24:30 CET 2017: Das Erste HD - Erlebnis Erde: Der Punkvogel aus dem Mittelalter (Film von Angelika Vogel und Angela Schmid) from Tvheadend schedule
1485098670
It seems to be specific to that show actually. I tried adding another episode of it ("Die Tagesschau vor 25 Jahren" on german tv channel ARD-alpha) on a complete different day, and suddenly i get the error again.
$ ./test-autosuspend-function.sh FindNextActivity
jq: error (at <stdin>:1): Cannot iterate over null (null)
AutoSuspend: Fetched next 0 upcoming recordings from Tvheadend
Afterwards curl, which resulted in an 401 UNAUTHORIZED, checking on it, it was because
$TVHEADEND_USER:$TVHEADEND_PASSWORD are not set. Are they supposed to be populated after running the test script? Because they both were empty.
No, they are not, I expected you to change the values as you did. Sorry that I didn't mention it.
Thanks for pointing out the problematic JSON entry. I think I found the problem. The error occurs when the JSON contains no information about a subtitle. Every show in my tests had one, so I didn't handle this situation. I made a fix, please pull commit a2d5792 or later, and check if it works for you.
Works again, thanks a lot for the help and making this script to begin with :)