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 sounds like the add-on I am looking for.

I'm running XBMC on a Raspberry PI (in Raspbmc). I'm also using the same PI as Squeezelite player.
Unfortunately, with both programs running, I can not play DTS movies over HDMI, as the Squeezelite seems to be blocking the audio somehow.

If I stop the Squeezelite service there is no problem.

So now I'm hoping that your add-on can help me to stop Squeezelite when video starts and then start the Squeezelite again after the video stops?
Quote:14:48:45 T:2903493440 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.MemoryError'>
Error Contents:
Traceback (most recent call last):
File "/home/xbmc/.xbmc/addons/service.xbmc.callbacks-0.2/default.py", line 115, in onScreensaverDeactivated
subprocess.Popen([script_screensaver_stops])
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1244, in _execute_child
data = _eintr_retry_call(os.read, errpipe_read, 1048576)
File "/usr/lib/python2.7/subprocess.py", line 478, in _eintr_retry_call
return func(*args)
MemoryError
-->End of Python script error report<--
Im getting this in some XBMC Crashlogs. is this something to ignore?
Thanks for this add-on, it's just what I was looking for. I've been trying to find an add-on which will log played media to a text file, but having established that nothing like that exists I decided I'd have to write one. Since I'm unfamiliar with XBMC development the task seemed a bit daunting, but I should be able to adapt your script to do what I need in no time.
(2013-12-16, 12:59)crax Wrote: [ -> ]This sounds like the add-on I am looking for.

I'm running XBMC on a Raspberry PI (in Raspbmc). I'm also using the same PI as Squeezelite player.
Unfortunately, with both programs running, I can not play DTS movies over HDMI, as the Squeezelite seems to be blocking the audio somehow.

If I stop the Squeezelite service there is no problem.

So now I'm hoping that your add-on can help me to stop Squeezelite when video starts and then start the Squeezelite again after the video stops?


Sure you can do it. I use it myself for something really similar in the same raspberry! Here is the script that I have to start hyperion when a video is played.

Code:
#!/usr/bin/env python

import os
import sys

# Check if not music
if not 'music' in sys.argv[1]:
  os.system('initctl start hyperion')

You should change the code inside os.system to suit your needs, save this command in any folder and configure the addon to execute the command when playback starts (and do something similar for when the playback is stopped).

Hope it helps.

(2013-12-16, 16:04)sIRwa2 Wrote: [ -> ]
Quote:14:48:45 T:2903493440 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.MemoryError'>
Error Contents:
Traceback (most recent call last):
File "/home/xbmc/.xbmc/addons/service.xbmc.callbacks-0.2/default.py", line 115, in onScreensaverDeactivated
subprocess.Popen([script_screensaver_stops])
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1244, in _execute_child
data = _eintr_retry_call(os.read, errpipe_read, 1048576)
File "/usr/lib/python2.7/subprocess.py", line 478, in _eintr_retry_call
return func(*args)
MemoryError
-->End of Python script error report<--
Im getting this in some XBMC Crashlogs. is this something to ignore?

Does your script work? I mean, it gets executed and do what you intented? My initial guess is that maybe the scripts fails for some reason and that crashes the addon Sad

Could you please let me know the OS you run xbmc and if you can execute the script outside XBMC with no problems?

Regards!
Quote:Could you please let me know the OS you run xbmc and if you can execute the script outside XBMC with no problems?

Im running XBMCBuntu, the scripts run fine in terminal, but i have not seen the error in the newer log's, so i guess its a "one off" i do have some issues with xbmc but i think its related to mysql video-database sharing rather then to callback Smile
Hi,

Is it possible to run script after library update/clean?
(2013-12-30, 21:56)birno Wrote: [ -> ]Hi,

Is it possible to run script after library update/clean?

I have added an option for that. Use v0.4 of the script (please it is not tested at all so let me know if it does not work!!)

https://github.com/pilluli/service.xbmc....e/v0.4.zip

Regards,
(2013-12-31, 13:06)pilluli Wrote: [ -> ]I have added an option for that. Use v0.4 of the script (please it is not tested at all so let me know if it does not work!!)

https://github.com/pilluli/service.xbmc....e/v0.4.zip

Regards,

Works perfectly, thank you!
I've got a RPi and I'm wondering if a script could be written to do the following:

When I play a movie on RPi, CEC automatically switches my TV's HDMI to the Pi which is great. What I'd like to do is that when the movie ends instead of going back to the XBMC menu have the script send a command to switch the HDMI back to the Cable Box input (say HDMI 1).

I'm using XBMC Touch on iPads so I'm trying to insulate the xbmc menu's since everything is presented in a very pleasing way on the iPad. Having auto HDMI switching also removes the need to grab a remote and cycle through all the inputs once your done watching a movie to get back to regular TV.

Would it be possible to do this using a script and your add-on?

Thanks a bunch.

Roveer.
Hi, great add-on. I have a feature request Big Grin

I'd like to use this to send the aspect ratio of the video playing to an external application, which will then adjust my screen masking and projector settings accordingly. Would it be possible to send this (or other information on the current video) as a custom parameter?
(2014-01-03, 08:48)bronco70 Wrote: [ -> ]Hi, great add-on. I have a feature request Big Grin

I'd like to use this to send the aspect ratio of the video playing to an external application, which will then adjust my screen masking and projector settings accordingly. Would it be possible to send this (or other information on the current video) as a custom parameter?

Maybe you can do this with the RPC API, just check the available functions and their return values.
So you can call a parameterless script, which ask the needed information through RPC then call the other script with parameters.
This is perfect! I just picked up the Phillips Hue lights, and this will work great for dimming the lights on movie play/resume and bringing them back up on resume/stop. Looking forward to trying it out tonight.
(2014-01-03, 08:48)bronco70 Wrote: [ -> ]Hi, great add-on. I have a feature request Big Grin

I'd like to use this to send the aspect ratio of the video playing to an external application, which will then adjust my screen masking and projector settings accordingly. Would it be possible to send this (or other information on the current video) as a custom parameter?

As best as I can tell, the XBMC python classes do not directly expose the aspect ratio for the file being played, however, using the filename, you can retrieve this information using a wrapper to the freely available and widely used mediainfo.dll, at least in windows. I am aware that versions exist for other OS's and the source is available for compilation on other platforms, but I have no experience there.
Can this add-on possible execute the following command on video stop? Oh, I'm using a Raspberry Pi on Openelec.

echo "tx 4F 82 10 00" | cec-client -s


What this does is tells CEC to change HDMI to port 1.

Not being a full blown programmer I'm kind of feeling my way in the dark. If someone can help me out a bit here I think I can get XBMC to do what I want.

Thanks.

Roveer
hello, thx for this addon, exactly what i needed Smile
question: how can i put as an argument to the called script the name of the movie that is being read/stopped?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23