Python script to be notified of channel lineup changes

Looks promising, but I did need to make one change to the code (and related comment) at lines 331 and 335:

def create_data_subdirectory(ip_address, port_number):
    '''
    Create a directory with the path as:
    current directory + "_<ip_address>-<port_number>_data" at the end
    '''
    global Data_Subdirectory_Path

    end_of_path = f'{ip_address}-{port_number}_data'
    data_subdirectory_path = os.path.join(os.getcwd(), end_of_path)

    if not os.path.exists(data_subdirectory_path):
        os.mkdir(data_subdirectory_path)
        
    Data_Subdirectory_Path = data_subdirectory_path

"_" changed to "-" between {ip_address} and {port_number}

On first run the data files ended up under /root again, but this time I cleverly :slight_smile: changed the directory to /config before running the script. Don't know why I didn't think of that before. It's good to have the data files in a subdirectory though.

1 Like

Thanks for the feedback and the code change. I'll make the correction. :slightly_smiling_face:

I'm curious: when you refer to "./” in OliveTin, what is the actual full path for this current directory?

/config is the usual working directory for most scripts, as that's the one that's bound to the host. All the scripts are there, as well as logs and other data-files -- some of which are in sub-directories.

I'm not landing in that directory on container start though, and I use the full path for many/most things, since a container has a completely predictable file system. It'd probably make sense to just change to /config at container start, as opposed to doing it as needed for a given script.

1 Like

OK so you don't think I need to make any more changes in my script with regard to the directory names?
I think this is what I'm understanding but please confirm. :slightly_smiling_face:

Yes -- all good! Just the "-" change referenced above.

New OliveTin-for-Channels pushed incorporating the latest 3.x version of this excellent script:

1 Like

Thanks much for the new improved script!
Especially the persistent reference files that keep track of channels between runs/restarts.

Have a question regarding this

I don't see the duplicate channels called out, for instance in my Pluto source. Are they supposed to appear? I'm not doing text/email notifications as that's overkill for me. Just looking in the log file.

Using Channels DVR server at: http://192.168.1.4:8489.
Checking for channel lineup changes every 720 minutes.

Visual monitoring only, no email or text will be sent.

Last check    : 2024-02-10 11:10:58
Server version: 2024.02.10.0353

Channels DVR server URL: http://192.168.1.4:8489
Channels DVR version: 2024.02.10.0353

New source with 391 channels: "Pluto"
See file /config/192.168.1.4-8489_data/Pluto.txt for the full lineup.

New source with 523 channels: "HDHomeRun PRIME"
See file /config/192.168.1.4-8489_data/HDHomeRun_PRIME.txt for the full lineup.

Next check: 2024-02-10 23:10:58

Here's what I'm seeing in media-server6-8089_channels_dvr_monitor_channels_latest.log:

Using Channels DVR server at: http://media-server6:8089.
Checking for channel lineup changes every 30 minutes.

An email will be sent to [email protected] when changes are detected.

Last check    : 2024-02-10 09:44:55
Server version: 2024.02.08.0626

Channels DVR server URL: http://media-server6:8089
Channels DVR version: 2024.02.08.0626

--------------------------

Pluto TV: 390 channels (-1)
(http://htpc6:8183/playlist.m3u)

<--- Lineup changes (starting at 0) --->
! 2480 : NFL Channel (was Hot Bench)
- 2800 : NFL Channel

<--- Channel changes --->
- Hot Bench (2480)

<--- Duplicated channels --->
AspireTV Life: 262, 3220
BET Her: 2050, 258
BET Pluto TV: 2040, 256
Black Cinema: 130, 250
Black Classics: 254, 530
Black Throwbacks: 252, 320
CBS News Chicago: 2570, 5120
CBS News Colorado: 2540, 5130
CBS News Los Angeles: 2560, 5150
CBS News New York: 2550, 5180
Love & Hip Hop: 1690, 264
Vevo R&B: 266, 4730
XITE Gospel: 268, 4800

Sending email to [email protected]...
Message sent successfully!

Next check: 2024-02-10 10:14:55

Last check    : 2024-02-10 10:14:56
Server version: 2024.02.08.0626
No changes found in any source.
Next check: 2024-02-10 10:44:56

Last check    : 2024-02-10 10:44:56
Server version: 2024.02.08.0626
No changes found in any source.
Next check: 2024-02-10 11:14:56

Last check    : 2024-02-10 11:14:56
Server version: 2024.02.08.0626
No changes found in any source.
Next check: 2024-02-10 11:44:56

Last check    : 2024-02-10 11:44:56
Server version: 2024.02.08.0626
No changes found in any source.
Next check: 2024-02-10 12:14:56

Last check    : 2024-02-10 12:14:56
Server version: 2024.02.08.0626
No changes found in any source.
Next check: 2024-02-10 12:44:56

Last check    : 2024-02-10 12:44:56
Server version: 2024.02.08.0626
No changes found in any source.
Next check: 2024-02-10 13:14:56

Checking every 30 minutes atm for "stress testing". I'm not doing PERSISTENT_LOGS though, so I'm not sure what my first run looked like anymore. @chDVRuser maybe shorten your interval for testing purposes, and see if the next run shows the dups?

Nope. Changed it to a 5 minute interval


Using Channels DVR server at: http://192.168.1.4:8489.
Checking for channel lineup changes every 720 minutes.

Visual monitoring only, no email or text will be sent.

Last check    : 2024-02-10 11:10:58
Server version: 2024.02.10.0353

Channels DVR server URL: http://192.168.1.4:8489
Channels DVR version: 2024.02.10.0353

New source with 391 channels: "Pluto"
See file /config/192.168.1.4-8489_data/Pluto.txt for the full lineup.

New source with 523 channels: "HDHomeRun PRIME"
See file /config/192.168.1.4-8489_data/HDHomeRun_PRIME.txt for the full lineup.

Next check: 2024-02-10 23:10:58


Using Channels DVR server at: http://192.168.1.4:8489.
Checking for channel lineup changes every 5 minutes.

Visual monitoring only, no email or text will be sent.

Last check    : 2024-02-10 12:26:22
Server version: 2024.02.10.0353
No changes found in any source.
Next check: 2024-02-10 12:31:22

Last check    : 2024-02-10 12:31:23
Server version: 2024.02.10.0353
No changes found in any source.
Next check: 2024-02-10 12:36:23

Last check    : 2024-02-10 12:36:23
Server version: 2024.02.10.0353
No changes found in any source.
Next check: 2024-02-10 12:41:23

Last check    : 2024-02-10 12:41:23
Server version: 2024.02.10.0353
No changes found in any source.
Next check: 2024-02-10 12:46:23

Last check    : 2024-02-10 12:46:24
Server version: 2024.02.10.0353
No changes found in any source.
Next check: 2024-02-10 12:51:24

Last check    : 2024-02-10 12:51:24
Server version: 2024.02.10.0353
No changes found in any source.
Next check: 2024-02-10 12:56:24

@chDVRuser in the case where a new source is found, the script doesn't check the lineup itself, it just reports the new source and the number of channels

That's one thing I didn't think of.

Duplicated channels get reported only if a lineup has changed.

I can add it.

Ahh, thanks for the explanation.
No need to add it as I just wanted to make sure the log file contained the same detailed message that would be emailed. I'm over-notified of too many things and don't need text msgs/email that channel lineups have changed!

Text msg says check your email
Email says check a wesbite
Website says Check your secure messages
I had already logged in the Website and read the Secure message

Yes. Unless I made a mistake in the code, the contents of the log file and the email should be the same. :slightly_smiling_face:

Is this from OliveTin? That's not from my script. :thinking:

No. Just in general. Over Notified.

I see. Got it. :wink:

@bnhf and @chDVRuser
I got a change in my Pluto TV source today. I'm expecting that you should get it too.
I'm curious to get your feedback about the reported changes that you will see.

Looking good. :+1:
Picked up changes on two of my servers.

Channels DVR version: 2024.02.11.0311

--------------------------

Fubo bridge: 236 channels (-1)
(http://192.168.1.3:7777/fubo/playlist-hls.m3u)

<--- Lineup changes (starting at 9000) --->
- 9238 : CBS 4K

<--- Channel changes --->
- CBS 4K (9238)

<--- Duplicated channels --->
Big Ten Network Alternate: 9022, 9023, 9024

Channels DVR version: 2024.02.11.0311

--------------------------

Pluto: 393 channels (+2)
(http://192.168.1.3:8080/playlist.m3u)

<--- Lineup changes (starting at 9001) --->
+ 9476 : Little House on the Prairie
+ 9477 : She Wrote

<--- Channel changes --->
+ Little House on the Prairie (9476)
+ She Wrote (9477)

<--- Duplicated channels --->
AspireTV Life: 9363, 9454
BET Her: 9047, 9452
BET Pluto TV: 9046, 9451
Black Cinema: 9013, 9448
Black Classics: 9164, 9450
Black Throwbacks: 9149, 9449
CBS News Chicago: 9061, 9342
CBS News Los Angeles: 9060, 9345
CBS News New York: 9059, 9348
CBS News Sacramento: 9058, 9352
Love & Hip Hop: 9108, 9455
Vevo R&B: 9260, 9456
XITE Gospel: 9358, 9457
1 Like

Great, @chDVRuser! :smiley:

I'm curious about Big Ten Network Alternate on Fubo. Is that right that it appears 3 times on 3 consecutive channel numbers? :hushed: Are they different versions?

Also, it looks like the two examples that you posted came from the same server machine at 192.168.1.3.
How can it be that Fubo starts at 9000 and Pluto at 9001? That's not a bug in my script?
I can see that they are from two different dockers so maybe they are used by different Channels DVR servers?

I have everything on one machine so it was strange at first for me to wrap my head around your configuration. I'm guessing you have something like this:

The Big Ten alternates are different feeds, but typically only show different games during football season.

1 Like

Here's mine copied from the e-mail notification:

Channels DVR server URL: http://media-server6:8089
Channels DVR version: 2024.02.11.0311

--------------------------

Pluto TV: 392 channels (+2)
(http://htpc6:8183/playlist.m3u)

<--- Lineup changes (starting at 0) --->
+ 640 : Little House on the Prairie
+ 690 : She Wrote

<--- Channel changes --->
+ Little House on the Prairie (640)
+ She Wrote (690)

<--- Duplicated channels --->
AspireTV Life: 262, 3220
BET Her: 2050, 258
BET Pluto TV: 2040, 256
Black Cinema: 130, 250
Black Classics: 254, 530
Black Throwbacks: 252, 320
CBS News Chicago: 2570, 5120
CBS News Colorado: 2540, 5130
CBS News Los Angeles: 2560, 5150
CBS News New York: 2550, 5180
Love & Hip Hop: 1690, 264
Vevo R&B: 266, 4730
XITE Gospel: 268, 4800

--------------------------

Samsung TV Plus: 330 channels (+1)
(http://htpc6:8182/playlist.m3u)

<--- Lineup changes (starting at 1002) --->
- 1001 : Heartland
! 1002 : LOL! Network (was Ebony TV by Lionsgate)
! 1003 : Bring It! (was 60 Days In by A&E)
+ 1054 : EBONY TV by Lionsgate
+ 1058 : Heartland
+ 1122 : 60 Days In by A&E
+ 1207 : PBS Antiques Roadshow
- 1247 : Bring It!
! 1284 : FreeTV Estelar (was Tu Cine)
- 1325 : LOL! Network

<--- Channel changes --->
+ EBONY TV by Lionsgate (1054)
- Ebony TV by Lionsgate (1002)
+ FreeTV Estelar (1284)
+ PBS Antiques Roadshow (1207)
- Tu Cine (1284)

--------------------------

FrndlyTV-noEPG: 6 channels (+1)

<--- Lineup changes (starting at 9657) --->
+ 9807 : Bounce

<--- Channel changes --->
+ Bounce (9807)
1 Like

Nice! So you got an email. That's good. :slightly_smiling_face:

All the channel numbers (including starting numbers) are reported correctly?