Page 1 of 3

Default to custom posters if Kodi/Plex connection lost

Posted: Sat Feb 08, 2020 10:42 pm
by RockDawg
We only use our theater room once or twice a week and I've had a couple instances where my Nvidia Shield has exited out of Kodi for some reason. So when I initially go downstairs MovieNow is just showing a black screen until I go into the theater room and start Kodi. Certainly, this is not a problem with MovieNow! but it would be nice if MovieNow! would detect this lost connection and switch to custom posters so It is never displaying black screen. Ideally it would remember that it was set to display Kodi and when connection is reestablished it would automatically start showing Kodi posters. Even if that proves too much and we have to manually switch back to Kodi/Plex, I would still like to see this. It would help eliminate any instance of MovieNow! not displaying a poster.

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Sat Feb 08, 2020 11:38 pm
by 0raid
you can do it already with a small script and the schedule feature!

1) connect to your Rpi terminal [server: movienow.local or Rpi IP address , username: pi , password: movienow
2) sudo bash [enter]
3) cd /var/www/html/settings/ [enter]
4) nano kodistatus.sh [enter]
5) copy paste the code:

* replace the 192.168.5.180 with your kodi IP *

Code: Select all

# check if KODI is responding
if ping -q -c 1 -W 1 192.168.5.180 >/dev/null; then
# if KODI is UP - do nothing
else
# if KODI is offline swich to custom posters
DISPLAY=:0.0
export DISPLAY
xhost +
xdotool key ctrl+3
fi
6) CTRL + O (you will see in the bottom (File Name to Write: kodistatus.sh) [enter]
7) CTRL + X [enter]
8) chmod +x kodistatus.sh [enter]

test the script:

./kodistatus.sh [enter]

if everything works great (ignore any error in terminal), just look if change the view from KODI to Custom when KODI is OFF!

Now open the web interface > Schedule > New CronJob

if you want to check every minute in the left options put in all the fields * (check also the screenshot)

and finally in the right , put the command of where is the script (this is the full path)

sudo /var/www/html/settings/kodistatus.sh

and press save New CronJob!

DONE! , schedule is running the kodistatus.sh script every minute to check if KODI is ONLINE or NOT!

**** The Schedule Feature its very powerfull , you can make and run anything you can imagine!! ****

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Wed Feb 12, 2020 3:54 pm
by RockDawg
I haven't yet tried this but I'm thinking this won't work in my situation. It appears to be determining if Kodi is running by pinging an IP address. The issue is that Kodi doesn't have it's own IP address. The machine it runs on does. So even if Kodi is not running, the machine will still respond to the ping.

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Wed Feb 12, 2020 10:19 pm
by 0raid
yes the script its only for people who run KODI in dedicated device! (openelenc. coreelec , libreelec)

i will add another script which ping IP and specific port (KODI port)

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Wed Feb 26, 2020 2:01 am
by RockDawg
So I went down to the theater tonight and again my Shield had exited out of Kodi so my poster TV was displaying a black screen when I first went down. Researching a little I found someone mention the nc command and it seems to work. Can you offer an assistance on how to alter your previous script for this command?

192.168.1.30 is a Shield box with Kodi running and 192.168.1.32 is a box where Kodi is closed.

Code: Select all

pi@movienow:~$ nc -vz 192.168.1.30 8080
Connection to 192.168.1.30 8080 port [tcp/http-alt] succeeded!
pi@movienow:~$ nc -vz 192.168.1.32 8080
nc: connect to 192.168.1.32 port 8080 (tcp) failed: Connection refused
pi@movienow:~$

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Wed Mar 11, 2020 6:17 am
by MidnightWatcher
If it hasn't been added yet, I think this should be the default behaviour when we select Kodi posters. If Kodi isn't playing a movie then display posters from another directory.

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Sat Mar 14, 2020 4:02 pm
by ae0705t
The last comment in this thread sounds like it doubles with another request ... if Kodi/Plex isn't playing, use another Poster category. I would LOVE that one.

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Sat Mar 14, 2020 4:46 pm
by MidnightWatcher
In my case, I have a bunch of 70's and 80's nostalgic posters in the Classic folder and I have these selected to play. When a movie isn't playing in Kodi I'd like these posters displaying again.

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Sun Mar 15, 2020 12:37 am
by tomoffel
I"ve gave this a shot and got it to work with my kodi setup

My Kodi is running on my firetv stick, so its not every time active. I've modified the script to check If the port is open, if so, switch to the kodi tab, if not, switch to the custom tab

Code: Select all

#!/bin/bash
SERVER=192.168.1.43
PORT=8080
nc -z -v -w5 $SERVER $PORT &> /dev/null
result1=$?

#Do whatever you want

if [  "$result1" != 0 ]; then
  echo $?
  echo  port $PORT is closed on $SERVER
  sudo /var/www/html/settings/tab1.sh
else
  echo $?
  echo port $PORT is open on $SERVER
  sudo /var/www/html/settings/tab2.sh
fi
Change the Variables on top (SERVER and PORT) to your setup!

Hope someone will find this usefull!

MAybe I will extend it if I can find out which tab is active, so we can make it not switching away from the "welcome to the theater" poster and stuff!

Re: Default to custom posters if Kodi/Plex connection lost

Posted: Sun Mar 15, 2020 7:55 pm
by 0raid
tomoffel wrote:
Sun Mar 15, 2020 12:37 am
I"ve gave this a shot and got it to work with my kodi setup

My Kodi is running on my firetv stick, so its not every time active. I've modified the script to check If the port is open, if so, switch to the kodi tab, if not, switch to the custom tab

Code: Select all

#!/bin/bash
SERVER=192.168.1.43
PORT=8080
nc -z -v -w5 $SERVER $PORT &> /dev/null
result1=$?

#Do whatever you want

if [  "$result1" != 0 ]; then
  echo $?
  echo  port $PORT is closed on $SERVER
  sudo /var/www/html/settings/tab1.sh
else
  echo $?
  echo port $PORT is open on $SERVER
  sudo /var/www/html/settings/tab2.sh
fi
Change the Variables on top (SERVER and PORT) to your setup!

Hope someone will find this usefull!

MAybe I will extend it if I can find out which tab is active, so we can make it not switching away from the "welcome to the theater" poster and stuff!
Nice!