Python script to be notified of channel lineup changes

No, only on changes. I actually like knowing it ran even if there are no changes via the log file, but I'm also using the healthchecks.io option -- which notifies me if the script fails to run for any reason.

I would vote for retaining configurability, as we each have our preferences.

I do too. :slight_smile:
Having a log file that keeps on growing with no rotation, not so much.

I just had a thought. How about this as a compromise...

  • create a file called "last_activity.log"
  • when checking for changes, write to this file what was found (or not) at that moment
  • on the next check, overwrite the file and write the result of the check at that moment (and it will indicate the next time it will check)

This way, we still get to know if the script is still running, and the size of the activity log file is greatly reduced and managed.
I will also have the other log file that will only contain the lineup changes.

Thanks,
This is what I'm looking for.
If that's not possible, I'll just continue using my curl/jq scripts.

Not only is it possible, but it has already been implemented.

The way I did it though is with an option and this option is currently not being used/available in OliveTin.

I will change it to make it a standard feature without having to select an option.

2 Likes

Thanks. Will try it out when OliveTin for Channels is updated with it.

Version 3.1.0:

[IMPROVED] Typo in the name of the data sub-directory

[CHANGED] Logging the lineup changes is a standard feature now

[CHANGED] The log file will contain the lineup changes of the current year.
A new file is created every year with the year number in the name.

[NEW] File "last_activity.log" to log the result of the last check only

@bnhf you can update OliveTin at your earliest convenience. :slight_smile:

1 Like

Pushed as bnhf/olivetin:latest and bnhf/olivetin:2024.03.02 -- looks good!

2 Likes

Thanks guys! Looking good here.

Ran a quick test;

  • add an M3U source with one channel
  • add a second channel
  • delete the first channel
  • delete the M3U source
  • re add the M3U source

It picked up everything except deleting the M3U source (to be expected).

1 Like

:thinking:

If I can detect a new source, I can also detect one that has been removed.

Even though this shouldn't be a surprise to the user since 99.999% of the time, it is the user that removes a source, I will still add it. You never know, if someday there is a critical bug or something, this will detect it.

It doesn't hurt to add this detection. I'll throw it in for the same price. :laughing:

That is quite generous of you Sir. I would have thought it'd double the price :laughing:

When you're parsing /devices, any chance you can skip those with a null Lineup ("Lineup": "")
My HDHR Prime tuner is showing up in /devices on all my servers because Channels DVR sees it on the network.
Channels Settings-Sources-Prime

I only have one of the servers using it where I assigned a guide provider for it.

/devices

[
  {
    "Provider": "m3u",
    "DeviceID": "M3U-Pluto",
    "FriendlyName": "Pluto",
    "ModelNumber": "HDHRCOMPAT-1",
    "Lineup": "XMLTV-Pluto",
    "Channels": […]
  },
  {
    "DeviceID": "Redacted",
    "DeviceAuth": "123456789012345678901234",
    "IPAddress": "192.168.1.7",
    "TunerCount": 3,
    "IsLegacy": false,
    "FriendlyName": "HDHomeRun PRIME",
    "FirmwareName": "hdhomerun3_cablecard",
    "FirmwareVersion": "20230713",
    "ModelNumber": "HDHR3-CC",
    "Lineup": "", <--------------------- HDHR Tuner not assigned a Guide Provider
    "Channels": […]
  }
]
1 Like

Sure. That will be in the next version too. :slightly_smiling_face:

1 Like

I'm having problems getting the channels lineup script to run in olivetin. Any ideas of what to look for?

It looks like either a bug in my code or a specific corner case that I'm not handling properly.

Can you please provide the settings for all your sources?

@cyoungers Not sure if this is the issue, but you have a default value of "another-server" in with your environment variables, and I see that in the stderr output, which is never a good sign. Any env vars that don't apply to you need to have null values, or be deleted altogether, though I prefer to see you leave them (empty) in case of future need.

Also, are you using the latest docker-compose and env vars, as shown in the first post of the OliveTin thread?

Please try the suggestion from @bnhf first. :slightly_smiling_face:

If you still have the same problem after that, I will want to get more details from you as I wrote in my previous message.

I did have the second dvr defined, but now I've commented that out. I pulled the latest olivetin.

      #- CHANNELS_DVR_ALTERNATES=${CHANNELS_DVR2_HOST}:${CHANNELS_DVR2_PORT} # Space separated list of alternate Channels DVR servers to choose from in the form hostname:port or ip:port.

I'm still getting the "IndexError: list index out of range" message when I start the script.

This error is generated by my script.

Please provide the settings used in all your sources and I will take a look.

@cyoungers In addition to providing the sources settings requested above, there's a line in stderr that starts with "nohup" that runs off the page. If you could post that full line (with needed redactions) as text, that might be helpful as that's the line that calls the @mjitkop python script.

My env variables:

TAG=latest
DOMAIN=tail6d9e.ts.net
HOST_PORT=1337
CHANNELS_DVR_HOST=192.168.0.11
CHANNELS_DVR_PORT=8089
CHANNELS_DVR2_HOST=
CHANNELS_DVR2_PORT=
CHANNELS_CLIENTS=apple-tv
ALERT_SMTP_SERVER=smtp.gmail.com:587
[email protected]
ALERT_EMAIL_PASS={redacted}

ALERT_EMAIL_TO={redacted}@gmail.com
UPDATE_YAMLS=true
UPDATE_SCRIPTS=true
TZ=US/Pacific
HOST_DIR=/volume1/data
DVR_SHARE=/volume1/ChannelsDVR
LOGS_SHARE=/var/packages/ChannelsDVR/target/channels-dvr
HOST_SFS_PORT=8080
FOLDER=/web
PORTAINER_TOKEN={redacted}
PORTAINER_HOST=cjynas

Standard Error:

+ dvr=192.168.0.11:8089
++ echo 192.168.0.11:8089
++ awk -F: '{print $1}'
+ channelsHost=192.168.0.11
++ echo 192.168.0.11:8089
++ awk -F: '{print $2}'
+ channelsPort=8089
+ foregroundScript=channels_dvr_monitor_channels
++ ps -ef
++ grep '[p]ython3 .* -i 192.168.0.11 -p 8089'
++ awk '{print $2}'
+ runningScriptPID=
+ greenIcon='"icons/channels.png"'
+ purpleIcon='"https://community-assets.getchannels.com/original/2X/5/55232547f7e8f243069080b6aec0c71872f0f537.png"'
+ logFile=/config/192.168.0.11-8089_channels_dvr_monitor_channels_latest.log
+ [[ -f /config/192.168.0.11-8089_channels_dvr_monitor_channels_latest.log ]]
+ configFile=/config/config.yaml
+ cp /config/config.yaml /tmp
+ configTemp=/tmp/config.yaml
+ trap finish EXIT
+ frequency=30
+ [[ 30 == \0 ]]
+ [[ 30 != \0 ]]
+ sed -i '/#channels_dvr_monitor_channels frequency default/s/default: .* #/default: 30 #/' /tmp/config.yaml
+ email={redacted}@gmail.com
+ [[ {redacted}@gmail.com != \n\o\n\e ]]
+ optionalArguments='-e {redacted}@gmail.com'
+ sed -i '/#channels_dvr_monitor_channels email default/s/default: .* #/default: {redacted}@gmail.com #/' /tmp/config.yaml
+ password={redacted_password}
+ [[ {redacted_password} != \n\o\n\e ]]
+ optionalArguments='-e {redacted}@gmail.com -P {redacted_password}'
+ [email protected]
+ [[ [email protected] != \n\o\n\e ]]
+ optionalArguments='-e {redacted}@gmail.com -P {redacted_password} -r [email protected]'
+ sed -i '/#channels_dvr_monitor_channels recipient default/s/default: .* #/default: [email protected] #/' /tmp/config.yaml
+ text=none
+ [[ none != \n\o\n\e ]]
+ main
+ cd /config
+ scriptRun
++ ps -ef
++ grep '[p]ython3 .* -i 192.168.0.11 -p 8089'
++ awk '{print $2}'
+ runningScriptPID=
+ [[ -n '' ]]ralizedlxafqknqd
+ runningScriptPID=623
+ echo 'channels_dvr_monitor_channels.sh 192.168.0.11:8089 30 {redacted}@gmail.com {redacted_password} [email protected] none'
+ nohup python3 -u /config/channels_dvr_monitor_channels.py -i 192.168.0.11 -p 8089 -f 30 -e {redacted}@gmail.com -P {redacted_password} -r [email protected]
+ grep -q '(.*) #channels_dvr_monitor_channels' /tmp/config.yaml
+ [[ 1 == \1 ]]
++ date +%d%b%y_%H:%M
+ sed -i '/#channels_dvr_monitor_channels title/s/#/(09May24_14:19) #/' /tmp/config.yaml
+ sed -i '/#channels_dvr_monitor_channels icon/s|img src = .* width|img src = "icons/channels.png" width|' /tmp/config.yaml
+ sleep 2
+ cat /config/192.168.0.11-8089_channels_dvr_monitor_channels_latest.log
+ runningScripts
+ servers=($CHANNELS_DVR $CHANNELS_DVR_ALTERNATES)
+ for server in "${servers[@]}"
++ echo 192.168.0.11:8089
++ awk -F: '{print $1}'
+ serverHost=192.168.0.11
++ echo 192.168.0.11:8089
++ awk -F: '{print $2}'
+ serverPort=8089
++ ps -ef
++ grep '[p]ython3 .* -i 192.168.0.11 -p 8089'
++ awk '{print $2}'
+ activeProcess=
+ [[ -n '' ]]
+ finish
+ cp /tmp/config.yaml /config