Script to find out which pass triggered the recording of a program

I wrote a script that will tell you why a program was recorded or why a program is scheduled to be recorded.

If anybody is interested to try it and report any bugs. :slight_smile:

Not only does this script tell you what pass triggered a recording, but it also shows when a recording was scheduled manually, or if a program was imported into the library.

Also, the title doesn't have to be exact, you can type only a part of the title. Keep in mind, in this case, that you may get a lot results.

Here is an example that shows recordings triggered by a pass, imported programs in the library, and one manual recording:

python cdvr_find_pass.py -t "Big Brother"

> Using Channels DVR server located at: http://127.0.0.1:8089.
> 
> Looking for matches...
> 
> |----------------------|
> | Scheduled recordings |
> |----------------------|
> 
>  - Episode "Big Brother" S25E5 triggered by pass: "TiVo 013. Big Brother"
>    will be recorded on Sunday, 08/13/2023 @ 19:59:00 on channel 2
> 
>  - Episode "Big Brother" S25E6 triggered by pass: "TiVo 013. Big Brother"
>    will be recorded on Wednesday, 08/16/2023 @ 19:59:00 on channel 2
> 
>  - Episode "Big Brother" S25E7 triggered by pass: "TiVo 013. Big Brother"
>    will be recorded on Thursday, 08/17/2023 @ 21:00:00 on channel 2
> 
>  - Episode "Big Brother" S25E8 triggered by pass: "TiVo 013. Big Brother"
>    will be recorded on Sunday, 08/20/2023 @ 19:59:00 on channel 2
> 
>  - Episode "Big Brother" S25E9 triggered by pass: "TiVo 013. Big Brother"
>    will be recorded on Wednesday, 08/23/2023 @ 19:59:00 on channel 2
> 
>  - Episode "Big Brother" S25E10 triggered by pass: "TiVo 013. Big Brother"
>    will be recorded on Thursday, 08/24/2023 @ 21:00:00 on channel 2
> 
>  - Episode "Big Brother" S25E11 triggered by pass: "TiVo 013. Big Brother"
>    will be recorded on Sunday, 08/27/2023 @ 19:59:00 on channel 2
> 
> 
> |-------------------|
> | Library programs  |
> |-------------------|
> 
>  - Episode "Big Brother" S25E4 triggered by pass: "TiVo 013. Big Brother"
>     "D:\DVR\TV\Big Brother\Big Brother S25E04 2023-08-10-2100.mpg"
> 
>  - Episode "Big Brother" S25E3 triggered by pass: "TiVo 013. Big Brother"
>     "D:\DVR\TV\Big Brother\Big Brother S25E03 2023-08-09-1959.mpg"
> 
>  - Episode "Big Brother" S25E2 is an import:
>     "J:\TV\Big Brother\Season 25\Big Brother S25E02 2023-08-06-1959.mkv"
> 
>  - Episode "Big Brother" S25E1 is an import:
>     "J:\TV\Big Brother\Season 25\Big Brother S25E01 2023-08-02-1959.mkv"
> 
>  - Show "Big Brother: 25th Anniversary Celebration" is a manual recording.
>     "D:\DVR\TV\Big Brother 25th Anniversary Celebration\Big Brother 25th Anniversary Celebration 2023-07-26-2059.mpg"
1 Like

Example with a program in my schedule:

Run my script:

python cdvr_find_pass.py -t "Austin City Limits" -s 48 -e 12

> Using Channels DVR server located at: http://127.0.0.1:8089.
> 
> Looking for matches...
> 
> |----------------------|
> | Scheduled recordings |
> |----------------------|
> 
>  - Episode "Austin City Limits" S48E12 triggered by pass: "Concerts"
>    will be recorded on Sunday, August 20, 2023 02:00:00 AM Eastern Daylight Time

Example with a program already recorded and obviously in my library:

image

Run my script:

python cdvr_find_pass.py -t "A Safari Romance"

> Using Channels DVR server located at: http://127.0.0.1:8089.
> 
> Looking for matches...
> 
> |-------------------|
> | Library programs  |
> |-------------------|
> 
>  - Movie "A Safari Romance (2023)" triggered by pass: "Andrew Walker"
>     "D:\DVR\Movies\A Safari Romance (2023) 2023-08-12-1959.mpg"

Looks like it could be useful, but I haven't run a python script in years.
Figured I'd try it on my Synology NAS which has Python 3.8.15 pre-installed.
Getting an error that it can't find the dateutil module

File "/volume1/arkives/cdvr_find_pass.py", line 25, in <module>
from dateutil import tz
ModuleNotFoundError: No module named 'dateutil'

I remember now why I haven't run a python script in years :grin:

Thank you for reporting this issue.

I'm not sure if you are willing to give it a try but see this:

To be honest, I don't remember if I had to install it manually on my Windows machine or if it was part of the standard Python installation.

I will see if somehow I can work around it and not use this module.
I will see if other users report the same issue too.

Or, how about running the script from a computer that can actually host it and its dependencies? (I don't assume that this was meant to be run directly from a NAS, container, or otherwise minimally equipped install ...)

Thanks, but I'll pass on it for now. I already have curl/jq scripts setup to get most of what your utility provides without having to add more software.

I'm sure many users will find it useful.

Fair enough. Thank you for being the first to give it a try. :slightly_smiling_face:

1 Like

Based on the issue reported by @chDVRuser, I took another look at my code and realized that I was over thinking it when I tried to handle the times.
After simplifying the code, it turns out that the dateutil module is not needed at all so I removed it.

I uploaded a new version that should work better on simple systems. :crossed_fingers:

Looks good.

Gave it a quick test on all 4 of my servers and this is the only thing that stands out.
If an episode is listed as E0 (Episode 0), your output drops the E0 and following space as seen below.

|----------------------|
| Scheduled recordings |
|----------------------|

 - Episode "The Smurfs" S1triggered by pass: "The Smurfs (1981) 9 Seasons, 422 Episodes"
   will be recorded on Monday, 08/14/2023 @ 04:30:00 on channel 813

 - Episode "The Smurfs" S1E1 triggered by pass: "The Smurfs (1981) 9 Seasons, 422 Episodes"
   will be recorded on Wednesday, 08/16/2023 @ 04:00:00 on channel 813

|-------------------|
| Library programs  |
|-------------------|

 - Episode "The Smurfs" S1triggered by pass: "The Smurfs (1981) 9 Seasons, 422 Episodes"
    "/shares/dvr/TV/The Smurfs/The Smurfs S01E00 1981-09-26 King Smurf 2023-08-08-0420.mpg"

 - Episode "The Smurfs" S1E3 triggered by pass: "The Smurfs (1981) 9 Seasons, 422 Episodes"
    "/shares/dvr/TV/The Smurfs/The Smurfs S01E03 1981-09-19 St Smurf and the Dragon 2023-08-09-0430.mpg"
1 Like

Cool, it's not too bad. :grin:

Was the episode number actually present in the json data with the value 0 or was it empty?

In both cases (scheduled and recorded) there is no Episode in the json data, only Season 1.
I assume Channels DVR just adds Episode 0 when that happens.
Screenshot 2023-08-13 at 18-55-39 Channels Schedule
Screenshot 2023-08-13 at 18-53-46 Channels The Smurfs

1 Like

Thanks for taking the time to test it and report the issues, I really appreciate it.

I will make a fix so that it matches the behavior of Channels and use E0 by default when it's not provided. :slightly_smiling_face:

1 Like

Maybe if it's an episodic show you could default the Season and Episode to 0 instead of NULL if not found in the json.
if program.category in ["Episode", "Series"]:
I have recorded Series and Season Specials where they appear as S00E00, S00E02 and S05E00, etc. in Channels DVR.

Forget about Airing.Raw.program.entityType and Airing.Raw.program.subType
They're only in Gracenote EPG data.
Where Airing.Raw.program.entityType is "Episode"

Examples of Airing.Raw.program.entityType and Airing.Raw.program.subType
"entityType": "Episode","subType": "Miniseries",
"entityType": "Episode","subType": "Series",

"entityType": "Movie","subType": "Feature Film",
"entityType": "Movie","subType": "Short Film",
"entityType": "Movie","subType": "TV Movie",

"entityType": "Show","subType": "Series",
"entityType": "Show","subType": "Special",

1 Like

Thanks for the suggestion! I will implement as soon as I get the chance. :slight_smile:

As of the latest pre-release, the pass that is responsible for the recording is now linked to in the View Details modal:

8 Likes
1 Like
1 Like

Thanks! You saved me some work and time. :slightly_smiling_face:

1 Like
1 Like