Kodi Community Forum

Full Version: Run script on events?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm really interested in triggerring scripts on some Kodi events (Start video library update or clean, Found a new tvshow, found new episodes, ...)

Do you have any ideas about how to do that ?

I found ISY Event Handler1 : Allows the user to trigger ISY Home Automation actions when different events occur in XBMC. The possible events are XBMC Starting, XBMC Quitting, Movie Playback Started, Movie Playback Ended, Movie Paused, Movie Resumed, Music Playback Started, Music Playback Ended, Music Paused, Music Resumed. This allows Insteon and X10 lights to react to XBMC events.

=> So nothing about the scan.

May be I can try to use xbmc.Monitor class, there is onScanFinished(...) and onScanStarted(...), This is perfect for me. Big Grin

Now, I'm not a python developer but, I've merged piece of code from internet.

Folder: ~/.xbmc/scripts

Script: push-alerts.py
Code:
#!/usr/bin/python3.4
import xbmc
import subprocess

class PushAlerts(xbmc.Monitor):

    def __init__(self):
    xbmc.Monitor.__init__(self)

def onScanStarted(video):
    subprocess.call(["/home/pi/push.sh", "title", "Started"])
def onScanFinished(video):
    subprocess.call(["/home/pi/push.sh", "title", "Finished"])

alertmanager = PushAlerts()
After I want that Kodi launch my script automatically, I found an old post about autoexec.py, but it deprecated.


Someone can help me to finish this script ?
Thanks a lot !!!!!
Thanks this helped.