[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27) +---- Forum: Service Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=152) +---- Thread: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) (/showthread.php?tid=151011) |
RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2014-03-10 (2014-03-10, 10:28)flarc Wrote: Hello, thanks for your helps. The way the plugin is currently written, it does not parse the string 'wscript C:\..\huelight_high.vbs' into two separate arguments to be passed to subprocess.call(). And that python call needs the 'wscript' argument to be passed because it is being called without the shell=true option. If I have time I might fork the master branch and come up with a way to parameterize the strings for interpretation. Something along the lines of enclosing each individual parameter in curly brackets and then have the script parse them into a tuple that can be passed in subprocess.call(). Maybe pilluli can weigh in at some point... RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - pilluli - 2014-03-10 (2014-03-10, 18:00)KenV99 Wrote: The way the plugin is currently written, it does not parse the string 'wscript C:\..\huelight_high.vbs' into two separate arguments to be passed to subprocess.call(). Indeed KenV99 is right, the addon does not support adding arguments to scripts. flarc, can you try this: Go to the "default.py" file in the service.xbmc.callbacks addon (let me know if you cannot find the file) and substitute the line: Code: subprocess.call([script_player_pauses,self.playing_type()]) with this one: Code: subprocess.call(script_player_pauses + " " + self.playing_type(), shell=True) save the file, restart XBMC and configure the addon so it calls wscript with an argument: Code: <setting id="player_pauses" value="wscript C:\sarah\plugins\fred\bin\huelight_high.vbs" /> Let me know if it works... RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2014-03-10 I created a fork: https://github.com/KenV99/service.xbmc.callbacks This OPTIONALLY allows for individual commands and/or arguments to be enclosed by curly brackets in the settings.xml file. These will then be parsed and passed when subprocess.call is invoked. For example for 'wscript c:\test.vbs' at the command line, the xml should have '{wscript}{c:\test.vbs}'. Or more precisely, using the example from flarc the full line in the xml file would be: Code: <setting id="player_pauses" value="{wscript}{C:\sarah\plugins\fred\bin\huelight_high.vbs}" /> Let me know if this works and/or causes problems for anyone. Thanks again to pilluli for the original script/code. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - flarc - 2014-03-11 KenV99 and Pilluli, thank you very much for such quick answer to my issue. As soon as back from business trip i will test your solutions and get back to you. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - wolfgr - 2014-03-12 hello,i have no programing skills at all,i just want a script to make http request like "http://192.168.1.120/?button2on". What is the easiest way to do it?Thank you. EDIT: got it,i have 2 scripts ,lightson.py and lightsoff.py,when i run them they work fine,but from within the addon dont work. my settings: Code: <settings> what am i doing wrong? tested both frodo and gotham ,win8.1 RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2014-03-13 (2014-03-12, 23:28)wolfgr Wrote: hello,i have no programing skills at all,i just want a script to make http request like "http://192.168.1.120/?button2on". That looks like it should work. Is there anything in XBMC.log to indicate why it failed? RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - wolfgr - 2014-03-13 xbmc log doent shows anything relevant... my scripts are lights on Code: import os and lights off Code: import os i have instaled Python 33 and scripts are working in windows. I just cant make them work inside xbmc. Edit: got them to work inside xbmc,run when execute from file manager just fine(i removed "request"). But still nothing works from the addon... RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2014-03-13 (2014-03-13, 14:57)wolfgr Wrote: xbmc log doent shows anything relevant... I realized it's the same reason that flarc was having issues. The subprocess.call() in the script does not allow calling a program without designating it's executable. So you would have to create a .bat with something like "C:\python33\python.exe c:\python33\lightson.py" and call the .bat file. Or you could try using my fork and put the two commands in curly brackets. Or lastly, you could edit the the script's default.py as pilluli suggested, including the argument shell=true. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - wolfgr - 2014-03-13 tested all solutions....scripts and .bat files are working outside addon,with the addon i get crasses,python.exe has stoped working messages and syntax errors. ....i give up RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - pilluli - 2014-03-13 What do the logs say? They should show the add on calling the script ... and then the error is?? RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2014-03-14 (2014-03-13, 20:06)wolfgr Wrote: tested all solutions....scripts and .bat files are working outside addon,with the addon i get crasses,python.exe has stoped working messages and syntax errors. ....i give upOK, if you have turned debug on in XBMC and have no error messages and would prefer not to pursue any further help, then best of luck. However, since this is an free, open source project, your experience could help the developers and other users if you are willing to work on it a bit more. If you change your mind, I think we need the info from the logs. If you tried the .bat file, exactly what the bat file looked like and the exact error message or crash situation. If you tried the curly brackets, exactly what you had in the xml file. If you tried editing the python script directly, the actual code that you finally left in the script. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - flarc - 2014-03-14 (2014-03-10, 22:06)KenV99 Wrote: I created a fork: https://github.com/KenV99/service.xbmc.callbacks Hello KenV99. Your method+modified script worked! Thanks. Please note that replacing python script + changing settings.xml + restarting xbmc was not enough to make it work. i do not know why, but within xbmc i add to go into add-on configuration and revalidate it by clicking "ok" for the change to be taken into account. Probably a cache somewhere . Either way, my problem is solved. Now, for the sake of science , i will test this week-end pilluli's method also. Thx again. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - pilluli - 2014-03-14 Please do as if that works it requires less configuration changes than kenv99 approach. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - flarc - 2014-03-22 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: ----------------------------------------------------------------------- When i am in scenario1 (default case, not working), i see in the logs: Code: 10:53:24 T:4824 NOTICE: ----------------------------------------------------------------------- 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? RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - Newsleecher - 2014-03-22 Thanks Pilluli and KenV99. The work both of you did saved me a lot of time and effort. I use vbs so KenV99 fork worked out easiest for me since I just need to replace one file rather than make several edits. |