Kodi Community Forum

Full Version: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
This add-on works great on my Pi1 but after installing on Pi2 (OSMC) it doesn't run bash scripts.
Any suggestions please?
Thanks.
This, almost always, is a permissions issue.
But as has been mentioned OVER AND OVER on the forums, if you don't post your kodi.log to pastebin and put a link, it's pretty much impossible to provide useful help.
Hi,

I'm looking for something like !
I will try your script asap. Is it possible to call a bash with arguments on start and finished library update?
Is it possible to extract library results (like new added shows or movies episodes?)

That's was my initial post : 233156 (thread)
The database update event is launch at start or finish ?
(2015-07-25, 14:31)raspdealer Wrote: [ -> ]The database update event is launch at start or finish ?

Read here: http://mirrors.kodi.tv/docs/python-docs/...ml#Monitor

Edit: I realized after posting that the new(ish) start and finish events for the database are not fully implemented in the current release. I will post back once I have updated it. Sorry.
KenV99, thanks again for the great addon. Im attempting to manually start the TrakTV addon Rating dialog after media playback has stopped. I know where the python script is that should be executed:
C:\Users\MKANET\AppData\Roaming\Kodi\addons\script.trakt-master\rating.py

..however, I'm sure what to put in the XMBC.Callbacks2 parameters field. I would appreciate any help or tips you could offer.
(2015-07-25, 19:53)MKANET Wrote: [ -> ]KenV99, thanks again for the great addon. Im attempting to manually start the TrakTV addon Rating dialog after media playback has stopped. I know where the python script is that should be executed:
C:\Users\MKANET\AppData\Roaming\Kodi\addons\script.trakt-master\rating.py

..however, I'm sure what to put in the XMBC.Callbacks2 parameters field. I would appreciate any help or tips you could offer.

Choose OnPlaybackStopped, choose 'python' and then type/paste the full path to the script as you have listed above.
If you do not need to pass any information to the script when it's called, you don't need any parameters.
Actually, that's what I already had. But, nothing was happening when the script was being executed. Kodi log just shows it successfully getting executed. I presumed the script is looking for a parameter for it to work.
I don't have the trakt.tv addon installed but looking at the code on github, I noted the following:
1) rating.py is a module that is imported by other modules and does not have any code that executes
2) the addon runs as a service and there is substantial infrastructure that needs to be loaded before being able to provide a rating
3) there is no simple way for an external script to call code in another script (this is true of all addons)
4) the addon already implements events for Player.OnPlaybackStopped

So, in short, you cannot do what you are trying to do using XBMC.Callbacks2.
(2015-07-25, 14:31)raspdealer Wrote: [ -> ]The database update event is launch at start or finish ?

I updated the addon on Github.
Please download the latest version: https://github.com/KenV99/service.xbmc.callbacks2
I haven't extensively tested yet, so please let me know if there are any issues.
Hi, I tried to install the add-on on my RPI 2 (Kodi 14.2) by using the zip file but it is missing dependencies. I also tried to install it by uploading the contents of the zip into the \Userdata\addon_data\ directory but the add-on is not listed anywhere.
(2015-07-26, 17:32)bks84 Wrote: [ -> ]Hi, I tried to install the add-on on my RPI 2 (Kodi 14.2) by using the zip file but it is missing dependencies. I also tried to install it by uploading the contents of the zip into the \Userdata\addon_data\ directory but the add-on is not listed anywhere.

1) The addon requires the requests2 (script.module.requests2) library as a dependency. If you properly install from zip, Kodi should download and install the dependency.
2) That is the wrong directory. Depending on what OS you have on the RPI it should be something like '/storage/.kodi/addons/'. But if you direct install you may run into the same issue with the dependency.

If Kodi isn't finding requests2, it can be downloaded directly from: https://github.com/beenje/script.module.requests2
Hi KenV99, Thanks for looking into this. It looks like I wasn't even close at achieving what I wanted. There's an incompatibility issue between the track.tv addon and the DSPlayer version of Kodi which prevents this module from opening TrakTV ratings dialog box reliability. I was just looking for a way to avoid that issue.

(2015-07-26, 00:30)KenV99 Wrote: [ -> ]I don't have the trakt.tv addon installed but looking at the code on github, I noted the following:
1) rating.py is a module that is imported by other modules and does not have any code that executes
2) the addon runs as a service and there is substantial infrastructure that needs to be loaded before being able to provide a rating
3) there is no simple way for an external script to call code in another script (this is true of all addons)
4) the addon already implements events for Player.OnPlaybackStopped

So, in short, you cannot do what you are trying to do using XBMC.Callbacks2.
Hi everyone, new comer from the MCE world, and have been very impressed with kodi and how I can integrate it with my home automation.

Couple of quick questions though.

I know nothing of python but have cobbled together a few scripts that seem to be working for my lighting needs that can differentiate between night and day. BUT FOR THE LIFE OF ME I CANNOT GET RESUME TO WORK!!!! I was up until 4am the other night trying to make it do what I wanted.

Does kodi pass a media type argument on resume? After the amount of time I have spent on this I'm thinking its a no.

Basically when I watch a movie at night and I pause the lights behind my couch turn on. When I resume my hope would be that for a movie the light would turn back off, whereas for just regular tv watching I want all my lights to stay on. Which it currently doesn't do no matter what arguments I set.

Code:
import xbmc
import urllib2
import datetime


DAY, NIGHT = 1, 2
def check_time(time_to_check, on_time, off_time):
    if on_time > off_time:
        if time_to_check > on_time or time_to_check < off_time:
            return NIGHT, True
    elif on_time > off_time:
        if time_to_check > on_time and time_to_check < off_time:
            return DAY, True
    elif time_to_check == on_time:
        return None, True
    return None, False


on_time = datetime.time(18,00)
off_time = datetime.time(04,00)
timenow = datetime.datetime.now().time()
current_time = datetime.datetime.now().time()

when, matching = check_time(current_time, on_time, off_time)

if matching:
    if when == NIGHT:

    if 'movie' in sys.argv[1]:
        urllib2.urlopen('insert lighting url here')

    if 'episode' in sys.argv[1]:
            urllib2.urlopen('insert lighting url here')
            urllib2.urlopen('insert lighting url here')

Thanks in advance for any help or pointers offered.
(2015-07-24, 14:11)KenV99 Wrote: [ -> ]This, almost always, is a permissions issue.
But as has been mentioned OVER AND OVER on the forums, if you don't post your kodi.log to pastebin and put a link, it's pretty much impossible to provide useful help.

Here is my log: http://xbmclogs.com/pvfhmd9zj .

If I run script from shell it works. Thanks fro your reply.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23