Python script to be notified of channel lineup changes

I really like this idea, so I'm just trying this out in command line on a Windows 11 machine. I'm trying to monitor on a different PC than the one where Channels server is located and I get the error message below.

C:> python channels_dvr_monitor_channels.py -f 15 -i 192.168.88.240
Traceback (most recent call last):
File "C:\channels_dvr_monitor_channels.py", line 62, in
import argparse, glob, os, requests, smtplib, sys, time
ModuleNotFoundError: No module named 'requests'

1 Like

The "ModuleNotFoundError: No module named 'requests'" occurs when you forget to install the requests module before importing it or if you install it in an incorrect environment. To resolve this error, follow these steps:

  1. Install the requests module:

    • Open your terminal or command prompt.
    • Navigate to your project's root directory.
    • Run the following command to install the requests module:
      pip install requests
      
      If you're using Python 3, use:
      pip3 install requests
      
  2. Check your Python installation:

    • Make sure you have Python and pip installed.
    • If pip is not in your path, you can use:
      python -m pip install requests
      
      For Python 3:
      python3 -m pip install requests
      
  3. Alternative methods:

    • On Linux, you can use your system's package manager:
      • CentOS: sudo yum install python-requests
      • Debian/Ubuntu (Python 2): sudo apt-get install python-requests
      • Debian/Ubuntu (Python 3): sudo apt-get install python3-requests
    • On Windows, use:
      pip install requests
      
      Or if pip is not in your path:
      python -m pip install requests
      

Remember to install the requests module in the correct environment, and you should be good to go! :rocket:¹²³⁴⁵

Source: Conversation with Copilot, 5/31/2024
(1) python - ImportError: No module named requests - Stack Overflow. python - ImportError: No module named requests - Stack Overflow.
(2) ModuleNotFoundError: No module named 'requests' in Python. ModuleNotFoundError: No module named 'requests' in Python | bobbyhadz.
(3) Solved: ModuleNotFoundError: No module named 'requests' in Python 3. Solved: ModuleNotFoundError: No module named 'requests' in Python 3 | CyberITHub.
(4) ModuleNotFoundError: no module named 'requests' [Solved in Python Django]. ModuleNotFoundError: no module named 'requests' [Solved in Python Django].
(5) python - ModuleNotFoundError: No module named 'requests' - Stack Overflow. python - ModuleNotFoundError: No module named 'requests' - Stack Overflow.
(6) undefined. PyPI · The Python Package Index.
(7) undefined. requests · PyPI.

Thank you for the quick response! Installed the module; all is running now and the number of channels in the log for each source I have is the same as what is listed in Channels settings. Thank you again.

2 Likes

@daldana7296 are you using the latest version of the script, version 3.3.0?

Yes. It just did it's first update and logged correctly.

1 Like

Perfect. Thank you for confirming. :slightly_smiling_face:

And below is what I get with after reloading the Pluto source. It's looks like it's working very nicely!

Check time: 2024-05-31 09:54:47

Server version: 2024.05.26.0350

Channels DVR server URL: http://192.168.88.240:8089
Channels DVR version: 2024.05.26.0350


Pluto TV: 406 channels (+1)
(https://nocords.xyz/pluto/playlist.m3u)

<--- Lineup changes (starting at 0) --->

  • 4490 : Telemundo Noticias Noreste

<--- Channel changes --->

  • Telemundo Noticias Noreste (4490)

<--- Duplicated channels --->
CBS News Baltimore: 2540, 5070
CBS News Chicago: 2570, 5120
CBS News Los Angeles: 2560, 5150
CBS News New York: 2550, 5180
Pluto TV Cars: 0, 1560

Next check: 2024-05-31 10:09:47

1 Like

Latest version (v3.3.0) of this script incorporated into OliveTin-for-Channels, and pushed as bnhf/olivetin:latest with all the usual OliveTin bells and whistles:

screenshot-htpc6-2024.05.31-11_38_21

2 Likes

Thanks, @bnhf

Let me know if you can figure out how to enable a start time.
I will be manually removing and adding the one server to check tomorrow.
I have it start at 11:05 and check every 12 hrs

I haven't had enough time yet to sit down and work on my code. :worried:

No rush. Just letting you know that when you do, I'll test it.

1 Like

@chDVRuser I'm starting to think about adding a start time to my script.

In your case, would you want to be able to specify just a time or a combination of day + time?

Thanks, Just a 24hr time is fine. 00:00 - 23:59

I like checking mine after the daily morning guide fetch is done (09:00-11:00), but I have a few sources fetching the playlist and XMLTV using a cron job. Pluto is done every 2hrs and the fetch is done by 11:06, so that's when I have it checking my Pluto Server.

1 Like

New release!

Version 3.4.0

[NEW] Added option '-s' to specify a start time in 24-hour format

1 Like

@bnhf - The '-s' option is followed by HH:MM.

Example:

>python channels_dvr_monitor_channels.py -s 11:06

Script version 3.4.0

Using Channels DVR server at: http://127.0.0.1:8089.

The first check will be done when the current time is 11:06.
Checking for channel lineup changes every 30 minutes.

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

Channel lineup changes will be written to:
C:\Users\mjitk\Documents\Scripts\test\127.0.0.1-8089_data\2024_channel_lineup_changes.log

The last activity will be saved in:
C:\Users\mjitk\Documents\Scripts\test\127.0.0.1-8089_data\last_activity.log

Current time: 22:16
Waiting for 12h 50m until the current time is 11:06...

If the option is not used, it will behave as we already know and start immediately.

@chDVRuser - Hopefully, this will work for you.

1 Like

Thanks @mjitkop
When @bnhf adds it to OliveTin I will give it a try.
No rush, since I probably won't be able to do that until this weekend.

1 Like

New bnhf/olivetin:latest (aka bnhf/olivetin:2024.07.17) pushed with version 3.4.0 of this script, along with required changes to the OliveTin Action launching it:

2 Likes

Thanks @mjitkop and @bnhf

Not at home, but I remoted in thru Tailscale, updated OliveTin, killed the old notifications and started them again using the scheduled start time option.

All looks good per the STD OUT. They should start later tonight. If any issues, I'll post back tomorrow.


Script version 3.4.0

Using Channels DVR server at: http://192.168.1.4:8489.

The first check will be done when the current time is 23:06.
Checking for channel lineup changes every 720 minutes.

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

Channel lineup changes will be written to:
/config/192.168.1.4-8489_data/2024_channel_lineup_changes.log

The last activity will be saved in:
/config/192.168.1.4-8489_data/last_activity.log

Current time: 18:24
Waiting for 4h 42m until the current time is 23:06...
Background Channel Lineup Change Notifications process running for 192.168.1.4:8089
Background Channel Lineup Change Notifications process running for 192.168.1.4:8189
Background Channel Lineup Change Notifications process running for 192.168.1.4:8190
Background Channel Lineup Change Notifications process running for 192.168.1.4:8289
Background Channel Lineup Change Notifications process running for 192.168.1.4:8389
Background Channel Lineup Change Notifications process running for 192.168.1.4:8489
1 Like

Looking good. Thanks @mjitkop and @bnhf

1 Like