[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)

  Thread Rating:
  • 3 Votes - 4.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
activate Offline
Fan
Posts: 598
Joined: Feb 2011
Reputation: 1
Post: #76
Thanks. This is cool. I am using it on OS X. Wondering if anyone has been able to run an applescript. I can trigger an app but not a script file.

Edit: Thanks for the info, used bash script.

Macmini Server 2011 i7 Quad Core, OS 10.8.2, Amp Onkyo TX-SR308 USB WD drives 3x2TB TV Samsung Plasma 720p EyeTV Integration
There are only 10 kinds of people in this world, those who understand binary, and those who don't.



(This post was last modified: 2014-01-31 09:32 by activate.)
find quote
Kib Offline
Team XBMC
Posts: 3,239
Joined: Jan 2010
Reputation: 53
Location: NL
Post: #77
(2014-01-31 09:14)activate Wrote:  Thanks. This is cool. I am using it on OS X. Wondering if anyone has been able to run an applescript. I can trigger an app but not a script file.

Something like /usr/bin/osascript <scriptname> should work

Neon skin - v3.0.7 now available for XBMC 13 (Gotham)
find quote
joltman Offline
Junior Member
Posts: 7
Joined: Feb 2014
Reputation: 0
Post: #78
Is it possible for this add-on to detect which video add-on is being launched then perform an action? Specifically, when I have a certain video streaming add-on start, I'd like to call a script that activates a VPN. Then, when the video streaming add-on is stopped, I'd like to call a script to deactivate the VPN. And then if there's a different video streaming add-on started, it would call a different VPN script? Thanks!
find quote
lukeg01 Offline
Junior Member
Posts: 3
Joined: Jan 2014
Reputation: 0
Post: #79
hello,
verry nice script , but how to configure it? perhaps you could help me with a example, like execute /home/xbian/lightsoff.sh when a movie of tv show starts

ps Im just beginning with python so excuse me for my ignorance in the language

Luke
(This post was last modified: 2014-02-16 12:17 by lukeg01.)
find quote
lukeg01 Offline
Junior Member
Posts: 3
Joined: Jan 2014
Reputation: 0
Post: #80
sorry, i found out its really a plugin, i tough it was a script.
how to change it so it doesn't see music as a player?

luke
find quote
metheos Offline
Junior Member
Posts: 39
Joined: Jun 2011
Reputation: 4
Post: #81
Great add on! It does what I needed just fine. My only nitpick is that the script I put into the xbmc start option gets abandoned after exiting and shows up on the process list as a zombie! Not a big deal, but it would be nice if that didn't happen.
find quote
metheos Offline
Junior Member
Posts: 39
Joined: Jun 2011
Reputation: 4
Post: #82
(2014-02-21 02:02)metheos Wrote:  Great add on! It does what I needed just fine. My only nitpick is that the script I put into the xbmc start option gets abandoned after exiting and shows up on the process list as a zombie! Not a big deal, but it would be nice if that didn't happen.

I was able to get this to work by adding a wait to the process and pointing it to a script that forks the actual script.
Code:
class Main:
  def __init__(self):
    self._init_vars()
    self._init_property()
    global script_xbmc_starts
    if script_xbmc_starts:
      log('Going to execute script = "' + script_xbmc_starts + '"')
      try:
          process= subprocess.Popen([script_xbmc_starts])
          process.wait()
      except:
          log('Error executing script when xbmc starts')
    self._daemon()
find quote
pilluli Offline
Fan
Posts: 340
Joined: Jul 2006
Reputation: 1
Post: #83
(2014-02-22 20:19)metheos Wrote:  
(2014-02-21 02:02)metheos Wrote:  Great add on! It does what I needed just fine. My only nitpick is that the script I put into the xbmc start option gets abandoned after exiting and shows up on the process list as a zombie! Not a big deal, but it would be nice if that didn't happen.

I was able to get this to work by adding a wait to the process and pointing it to a script that forks the actual script.
Code:
class Main:
  def __init__(self):
    self._init_vars()
    self._init_property()
    global script_xbmc_starts
    if script_xbmc_starts:
      log('Going to execute script = "' + script_xbmc_starts + '"')
      try:
          process= subprocess.Popen([script_xbmc_starts])
          process.wait()
      except:
          log('Error executing script when xbmc starts')
    self._daemon()

Thanks for this, to be honest it does not happen in my setup (raspbmc) but I will investigate further. Regards,
find quote
pilluli Offline
Fan
Posts: 340
Joined: Jul 2006
Reputation: 1
Post: #84
Hi,

I have created a new version (v0.5) that I think fixes the possible zombie processes. Thanks for reporting this:

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

Regards,
find quote
jvc1986 Offline
Junior Member
Posts: 1
Joined: Mar 2014
Reputation: 0
Post: #85
How can I run a file with additional attributes, I need to be able to either:

1 - Link to a shortcut
or
2 - Be able to point to a program like this ""C:\Program Files (x86)\HomeSeer HS2\HsScript.exe" MovieStart.vb"

Is that possible somehow, because in the XBMC interface I can't manually type the script location
find quote
Samu-rai Offline
Posting Freak
Posts: 1,449
Joined: Sep 2012
Reputation: 39
Post: #86
(2014-03-01 09:40)jvc1986 Wrote:  How can I run a file with additional attributes, I need to be able to either:

1 - Link to a shortcut
or
2 - Be able to point to a program like this ""C:\Program Files (x86)\HomeSeer HS2\HsScript.exe" MovieStart.vb"

Is that possible somehow, because in the XBMC interface I can't manually type the script location

Yes, go to addon_data > service.xbmc.callbacks > and manually edit the settings.xml


I'm trying to run a script after library update, but I'm getting the following errors:

Code:
13:45:42 T:10988   DEBUG: XBMC callbacks: database updated
13:45:42 T:10988   DEBUG: XBMC callbacks: Going to execute script = "C:\Users\me\myscript.py"
13:45:42 T:10988   DEBUG: XBMC callbacks: ERROR executing script when database updates

The script will run if manually executed through XBMC so I know that it works.

Any ideas?

My fanart.tv & themoviedb.org accounts.

[Image: all-thin-banner.jpg]
(This post was last modified: 2014-03-02 21:06 by Samu-rai.)
find quote
Samu-rai Offline
Posting Freak
Posts: 1,449
Joined: Sep 2012
Reputation: 39
Post: #87
Sorry to bump this. It would be tremendous if I could get this working. The solution I've been looking for for months.

I would be eternally grateful for any advice that could be offered.

My fanart.tv & themoviedb.org accounts.

[Image: all-thin-banner.jpg]
(This post was last modified: 2014-03-07 00:43 by Samu-rai.)
find quote
flarc Offline
Junior Member
Posts: 8
Joined: Nov 2013
Reputation: 0
Post: #88
Hi all,

I am using this superb addon on windows.
I use it to pilot my philips hue: 20% light when player starts/resumes, and 100% light when player stops/pauses.
To do so, i create .bat file containing the curl command. It works.
However, when invoking the .bat, there is a console window opening briefly.
I would like the invocation to be invisible.

I tried "start /min light.bat", i tried also "wscript light.vbs" (with adequate code that does not show a window).
Both those fail to be started. And i have no error log. I do no why they are not started: maybe due to presence of an argument?

Any idea to mask that console window?
I currently returned back to .bat file, but it is not sexy...
find quote
KenV99 Offline
Senior Member
Posts: 203
Joined: Nov 2013
Reputation: 6
Post: #89
(2014-03-09 15:43)flarc Wrote:  Hi all,

I am using this superb addon on windows.
I use it to pilot my philips hue: 20% light when player starts/resumes, and 100% light when player stops/pauses.
To do so, i create .bat file containing the curl command. It works.
However, when invoking the .bat, there is a console window opening briefly.
I would like the invocation to be invisible.

I tried "start /min light.bat", i tried also "wscript light.vbs" (with adequate code that does not show a window).
Both those fail to be started. And i have no error log. I do no why they are not started: maybe due to presence of an argument?

Any idea to mask that console window?
I currently returned back to .bat file, but it is not sexy...

Can you post the code that you used in the .bat file as well as the code in the .vbs file?
Have you tried inserting a bit of code in either of those files to see if they are being executed? Like create a message box? Once done debugging then you would delete that code.
find quote
flarc Offline
Junior Member
Posts: 8
Joined: Nov 2013
Reputation: 0
Post: #90
Hello, thanks for your helps.

1) Ok, so currently, my settings.xml is like this:
Code:
<setting id="player_pauses" value="C:\sarah\plugins\fred\bin\huelight_high.bat" />

And the "huelight_high.bat" is like that:
Code:
@echo off
c:
cd C:\sarah\plugins\fred\bin
curl http://192.168.1.21/api/newdeveloper/lights/1/state -X PUT -d "{\"on\":true, \"bri\":228}" >> NUL

This works, but i see a brief console window appear.

2) I tried also this (xml manually edited because .vbs is not displayed in xbmc add-on configuration screen):

settings.xml:
Code:
<setting id="player_pauses" value="C:\sarah\plugins\fred\bin\huelight_high.vbs" />

huelight_high.vbs:
Code:
Set WshShell = WScript.CreateObject("WScript.Shell")
cmd = "C:\sarah\plugins\fred\bin\huelight_high.bat"
Return = WshShell.Run(cmd, 0, True)
set WshShell = Nothing

The huelight_high.bat is unchanged.

If i run manually the vbs, it works without console appearing.
But within XBMC, the command is not performed (which i can see only due to no change of light)

Does not work either with:
settings.xml:
Code:
<setting id="player_pauses" value="wscript C:\sarah\plugins\fred\bin\huelight_high.vbs" />

3) I also tried compiling the .bat into .exe, and updating accordingly the settings.xml, but does not work either.
Code:
<setting id="player_pauses" value="C:\sarah\plugins\fred\bin\huelight_high.exe" />

4) I did not try yet to put directly the long curl command into the settings.xml (i need to see how to manage the quotes within the command).

5) Last thing i would try (but i do not know yet how to do it) is calling directly a python script (that would be interpreted by xbmc's own python lib) to change hue lights.

If you have an idea to make option#1 or #2 work, it would be helpful, because i would prefer those ways of doing it. But if option#5 would work, i will take it.
(This post was last modified: 2014-03-10 10:31 by flarc.)
find quote
Post Reply