• 1
  • 6
  • 7
  • 8(current)
  • 9
  • 10
  • 23
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)
(2014-03-22, 12:07)flarc Wrote: Hello Pilluli,
I tried you method this morning it works too. Thanks.

I just however discovered an issue with the plugin, whether i use your default.py or KenV99: the plugin works only when i go into its settings and validate them before playing a video.
Let me explain better:
- scenario1: i just start xbmc, and then start a video: plugin does not trigger
- scenario2: i start xbmc, go into plugin config page, validate the config without changing it, return to homepage, and then start a video: it works.

I activated XBMC debug to see what happened.

In scenario2 (working case after config), i see that in the logs:
Code:
10:56:55 T:3004  NOTICE: -----------------------------------------------------------------------
10:56:55 T:3004  NOTICE: Starting XBMC (12.0 Git:20130127-fb595f2), Platform: Windows 7 32-bit, build 7600. Built on Jan 28 2013 (compiler 1600)
[...]
10:57:34 T:3004   DEBUG: ------ Window Init (DialogAddonSettings.xml) ------
[...]
10:57:37 T:4072   DEBUG: XBMC callbacks: Reading properties
10:57:37 T:4072   DEBUG: XBMC callbacks: script xbmc starts = ""
10:57:37 T:4072   DEBUG: XBMC callbacks: script player starts = "wscript C:\sarah\plugins\fred\bin\huelight_low.vbs"
10:57:37 T:4072   DEBUG: XBMC callbacks: script player stops = "wscript C:\sarah\plugins\fred\bin\huelight_high.vbs"
10:57:37 T:4072   DEBUG: XBMC callbacks: script player pauses = "wscript C:\sarah\plugins\fred\bin\huelight_high.vbs"
10:57:37 T:4072   DEBUG: XBMC callbacks: script player resumes = "wscript C:\sarah\plugins\fred\bin\huelight_low.vbs"
10:57:37 T:4072   DEBUG: XBMC callbacks: script screensaver starts = ""
10:57:37 T:4072   DEBUG: XBMC callbacks: script screensaver stops = ""
10:57:37 T:4072   DEBUG: XBMC callbacks: script idle = ""
10:57:37 T:4072   DEBUG: XBMC callbacks: db update = ""
[...]
10:57:50 T:4072   DEBUG: XBMC callbacks: player starts
10:57:50 T:4072   DEBUG: XBMC callbacks: Going to execute script = "wscript C:\sarah\plugins\fred\bin\huelight_low.vbs"

When i am in scenario1 (default case, not working), i see in the logs:
Code:
10:53:24 T:4824  NOTICE: -----------------------------------------------------------------------
10:53:24 T:4824  NOTICE: Starting XBMC (12.0 Git:20130127-fb595f2), Platform: Windows 7 32-bit, build 7600. Built on Jan 28 2013 (compiler 1600)
[...]
10:55:53 T:3032   DEBUG: XBMC callbacks: player starts

I looked into the default.py code, and it seems to me that in default case the properties are not loaded, so even though the event "player starts" is properly catched it does not trigger the subprocesscall.
For the properties to be read, i have to validate them at each xbmc start.
But, why?
I do not know if it is pertinent, but please note that i use xbmc in portable mode (started with '-p' )

My solution proposal would be to modify the default.py to hardcode within each callback function the value of the variable from settings.xml, so that it works even if the settings are not read.

Any other idea?

Hmmmm. I'm thinking that it definitely may be related to the portable mode, because I know for sure that the code retrieves the settings properly during initialization in the non-portable mode. In addition, when I step through using a debugger, that code is properly executed. The python extensions for XBMC do not provide alternate means of retrieving the settings in portable mode versus non-portable. The extension provides automatic path translation due to the differences in OS's.

I will look into running the debugger when starting in portable mode and tracing the calls, but I'll have to figure out the process of copying over my settings to the portable_data directory. Are you running from the Program Files directory using 'run as admin' or are you running from a different read/write directory?

The code as it stands should read the settings at initialization and whenever the settings change. Although it could be written to read the settings before each script call, I'd like to investigate why it's failing currently before resorting to that.

I'm also contemplating including code in my fork to directly execute url/http calls and more detailed error catching and logging. And optionally provide on-screen notifications when the scripts run to also help with debugging. If it seems to work well, perhaps I'll ask pilulli to consider pulling that code back into the master.
Reply
Registered just to post this message:
Thanks!

This addon was the missing link from XBMC events to controlling my lights. Smile
Reply
Hello KenV99.

"Are you running from the Program Files directory using 'run as admin' or are you running from a different read/write directory?"

I am running from the program files, yes.
Reply
Hi Guys,

I'm trying to call a simple python script from this addon, but the xbmc log shows it doesn't work:
Code:
Line 864: 10:04:13 T:2936144992   DEBUG: XBMC callbacks: Going to execute script = "/storage/downloads/playerstart.py"
Line 903: 10:04:14 T:2936144992   DEBUG: XBMC callbacks: ERROR executing script when player starts

The script sends a udp packet to my wifi-enabled light bulbs:
Code:
#!/usr/bin/python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto("\x42\x00\x55", ("192.168.0.197", 8899))

Currently, I can run the script without problem from the command line. Also python is installed correctly.
My settings.xml is as follows:
Code:
<setting id="player_starts" value="/storage/downloads/playerstart.py" />
<setting id="player_stops"  value="/storage/downloads/playerstop.py" />

Is there a way to get more debug info than the two lines shown in the XBMC debug window?
I'm going to try flarc's method today.
Reply
Fixed it by adding python
Code:
<setting id="player_starts" value=" python /storage/downloads/playerstart.py" />

Moreover, is there a way to find out the title of the movie/episode that is playing?
I tried:
Code:
if xbmc.getInfoLabel('VideoPlayer.Season') != "" and xbmc.getInfoLabel('VideoPlayer.TVShowTitle') != "":
   type = "episode" + xbmc.getInfoLabel('VideoPlayer.TVShowTitle')[/align]

and in my python script I call:
Code:
import sys

if 'movie' in sys.argv[1].lower():
    os.system("milight 0 C 40")
elif 'friends' in sys.argv[1].lower():
    os.system("milight 0 C 220")

But this does not work.
Reply
(2014-04-06, 13:59)Elessar88 Wrote: Fixed it by adding python
Code:
<setting id="player_starts" value=" python /storage/downloads/playerstart.py" />

Moreover, is there a way to find out the title of the movie/episode that is playing?
I tried:
Code:
if xbmc.getInfoLabel('VideoPlayer.Season') != "" and xbmc.getInfoLabel('VideoPlayer.TVShowTitle') != "":
   type = "episode" + xbmc.getInfoLabel('VideoPlayer.TVShowTitle')[/align]

and in my python script I call:
Code:
import sys

if 'movie' in sys.argv[1].lower():
    os.system("milight 0 C 40")
elif 'friends' in sys.argv[1].lower():
    os.system("milight 0 C 220")

But this does not work.

Since you seem adept at writing python, why not just put your python code directly in the default.py of the add-on in the class "MyPlayer" under the " def onPlayBackStarted(self):" method?
You can then use "self.getVideoInfoTag" to get the tag of the currently playing file and then "getTitle" to get the title...

See http://mirrors.xbmc.org/docs/python-docs.../xbmc.html
Reply
Hi Ken,

Not sure why I didn't think of that before, thanks Smile
Reply
I'm trying to add functionality to catch xbmc.shutdown but my python skills are very limited. I'm guessing this should be fairly simple to implement but please correct me if I'm wrong. I don't want to dig into your code unless this is possible. Could you perhaps point me in the right direction? Any help is appreciated.

Also, thanks for a neat add-on, it's very useful and works like a charm.
Reply
Great idea! I'm trying to use this to run Artwork Organiser whenever the database updates, but I've no idea if it's working as I get no feedback, nor any prompt that Artwork Organiser is running. Honestly I'm surprised that addon doesn't have a scheduler of its own!
Image
Reply
(2014-04-04, 17:09)flarc Wrote: Hello KenV99.

"Are you running from the Program Files directory using 'run as admin' or are you running from a different read/write directory?"

I am running from the program files, yes.

Hello KenV99.

I hardcoded the script command line into the the default.py, and now of course it works.

ex.:
Code:
[...]
def onPlayBackPaused(self):
    log('player pauses')
    global script_player_pauses
    script_player_pauses = 'wscript C:\\sarah\\plugins\\fred\\bin\\huelight_high.vbs'
    if script_player_pauses:
      log('Going to execute script = "' + script_player_pauses + '"')
[...]

As my config will be stable for a long time, i will stick with this unclean way to make it work.
Thx anyway for your support.
And thx to both Pilluli and you for the trick to make my command line work with space inside.
Reply
EDIT: Ignore, I have a low IQ; Permissions.

--==-=-=-=-=-=-==-=-=-=-=--=-=-=--=-=-=-
Hello. Love the script, except the only action it is doing now is writing errors to my debug log Smile

I have tried:
Quote:/Users/pyro/Desktop/wemo/pauseXBMC.sh
bash /Users/pyro/Desktop/wemo/pauseXBMC.sh
/bin/bash /Users/pyro/Desktop/wemo/pauseXBMC.sh

All the script does is simply make x=1;
Code:
#!/bin/bash
x=1;

Code:
13:32:36 T:4626214912   DEBUG: XBMC callbacks: player pauses
13:32:36 T:4626214912   DEBUG: XBMC callbacks: Going to execute script = "bash /Users/pyro/Desktop/wemo/pauseXBMC.sh"
13:32:36 T:4626214912   DEBUG: XBMC callbacks: ERROR executing script when player pauses

It is all the same. I am using 12.3 on a 10.9.3 mac mini

Thanks for the good work!
XBMC on MacMini + <12TB of material displaying on 60" or 150".
Image
Reply
I've been trying to use this addon to run another addon when the library updates.

But after almost 3 days of effort, with what appears to be no progress at all, I think I'm about to go insane Confused

I've tried to follow every suggestion through out this thread, but still no joy.

I would be very grateful if someone could offer some assistance.

The script is simple:

Code:
import xbmc

xbmc.executebuiltin("xbmc.RunScript(script.tv.show.next.aired)")

Now after reading all the info about needing to mark the script as executable etc, I thought it may be easier to just hardcode the above into the script as others have suggested:

Code:
def onDatabaseUpdated(self,db):
    log('database updated')
    global script_db_update
    if script_db_update:
      log('Going to execute script = "' + script_db_update + '"')
      try:
          #subprocess.call([script_db_update,db])
          xbmc.executebuiltin("xbmc.RunScript(script.tv.show.next.aired)")
      except:
          log('ERROR executing script when database updates')

But this doesn't appear to work either.

Although I have limited coding knowledge, I consider myself to be pretty knowledgeable when it comes to XBMC. However, this has me doubting that.

Where am I going wrong?

FYI - I am running a Linux build.
My fanart.tv & themoviedb.org accounts.

Image
Reply
Your xbmc.executebuiltin etc doesn't look like it is indented correctly. It should be at the same level as the # of the line above it.

You also need to ensure that you still have a database update script set, or just change the

Code:
if script_db_update:
To
Code:
if True:
Reply
Changing it to True worked!

I knew it would be something tiny, but I never would of got that.

Thanks spoyser. Much obliged.
My fanart.tv & themoviedb.org accounts.

Image
Reply
Can this script also launch scripts/commands on profile switching?
Reply
  • 1
  • 6
  • 7
  • 8(current)
  • 9
  • 10
  • 23

Logout Mark Read Team Forum Stats Members Help
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)4