[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
KenV99 Offline
Senior Member
Posts: 265
Joined: Nov 2013
Reputation: 8
Post: #166
(2014-12-10 17:52)spambus Wrote:  @kenv99 on linux your script works fine, but under windows when I try to open url's (trigger url's on an arduino wich controls lights) I get several errors

the errors is in default.py line 562, this part => u = urllib2.urlopen(self.cmd_str, timeout=20)

and then multiple errors then in the python part of kodi

the erorrs display in a window of your addon, can't copy the output

so basicly trigegring of url's under windows does not work,it works fine under linux, btw I'm using kodi helix rc3

I assume that it is in a window when using the 'Test' button?
I would need a log file and at least a copy of the script/command/url that you are using to even start to troubleshoot.
find quote
spambus Offline
Junior Member
Posts: 33
Joined: Aug 2013
Reputation: 0
Post: #167
this the error from the kodi log:

Code:
16:39:43 T:4664  NOTICE: $$$ xbmc.callbacks2 - Starting tester.py from cwd: C:\Users\HTPC\AppData\Roaming\Kodi\addons\service.xbmc.callbacks2-master
16:39:43 T:4664  NOTICE: $$$ [xbmc.callbacks2] - Executing command: [http://192.168.2.14/kca_start] for event: onStartup
16:39:43 T:4664  NOTICE: $$$ [xbmc.callbacks2] - Command for onStartup resulted in ERROR: <attribute 'message' of 'exceptions.BaseException' objects>
Traceback (most recent call last):
  File "C:\Users\HTPC\AppData\Roaming\Kodi\addons\service.xbmc.callbacks2-master\default.py", line 562, in run
    u = urllib2.urlopen(self.cmd_str, timeout=20)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 404, in open
    response = self._open(req, data)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 422, in _open
    '_open', req)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 1214, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 1187, in do_open
    r = h.getresponse(buffering=True)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\httplib.py", line 1067, in getresponse
    response.begin()
  File "C:\Program Files (x86)\Kodi\system\python\Lib\httplib.py", line 409, in begin
    version, status, reason = self._read_status()
  File "C:\Program Files (x86)\Kodi\system\python\Lib\httplib.py", line 373, in _read_status
    raise BadStatusLine(line)
BadStatusLine: ''

url I trigger is : http://192.168.2.14/kca_start

but you can see that also in the log above

all url's I try to trigger give the exact same error
(This post was last modified: 2014-12-10 18:37 by spambus.)
find quote
KenV99 Offline
Senior Member
Posts: 265
Joined: Nov 2013
Reputation: 8
Post: #168
Can you please try testing with the following:

1) Go to Settings->Services->Webserver and enable it and set the port to 9091 (or something else and then edit the url below)(you may need to turn on expert settings).
2) Copy/paste the following url into whatever event you are trying to setup:
Code:
http://localhost:9091/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22id%22:1,%22method%22:%22Application.​Setmute%22,%22params%22:{%22mute%22:%22toggle%22}}
3) Click OK and then go back and click test. It should mute the audio from Kodi and you should see an icon to that effect in the upper left, depending on your skin.

Thanks.
find quote
spambus Offline
Junior Member
Posts: 33
Joined: Aug 2013
Reputation: 0
Post: #169
the json url worked
find quote
KenV99 Offline
Senior Member
Posts: 265
Joined: Nov 2013
Reputation: 8
Post: #170
(2014-12-10 19:11)spambus Wrote:  the json url worked

Ok. Then I am not sure exactly what might be going on with your url. What do you see when you just browse to that url?
find quote
spambus Offline
Junior Member
Posts: 33
Joined: Aug 2013
Reputation: 0
Post: #171
when I browse to that url, I see nothing, that's the way I created it, it runs code from my own home automation system I created on an arduino mega 2560, basicly what it does on the arduino side, when I trigger the url: http://192.168.2.14/kca_start on the arduino there runs code, wich turns limitlessled lightbulbs on and off, and a pushover message is send to my phone/watch/tablet that kodi has started, I can also code that when the url is triggered though a browser, the browser displays: hello in html, or whatever, but that is not needed

The pushover message being send confirms that the code on the arduino has been executed
(This post was last modified: 2014-12-10 19:44 by spambus.)
find quote
KenV99 Offline
Senior Member
Posts: 265
Joined: Nov 2013
Reputation: 8
Post: #172
I uploaded a version with a little more debugging info to github:
https://github.com/KenV99/service.xbmc.c...master.zip

If you want to try that and look at the logs, that might be helpful.
find quote
spambus Offline
Junior Member
Posts: 33
Joined: Aug 2013
Reputation: 0
Post: #173
it gives the same error, not more details then before Confused

Code:
19:01:00 T:5320  NOTICE: $$$ [xbmc.callbacks2] - Executing command: [http://192.168.2.14/kca_pauze] for event: onPlaybackStopped
19:01:00 T:5320  NOTICE: $$$ [xbmc.callbacks2] - Command for onPlaybackStopped resulted in ERROR: <attribute 'message' of 'exceptions.BaseException' objects>
Traceback (most recent call last):
  File "C:\Users\HTPC\AppData\Roaming\Kodi\addons\service.xbmc.callbacks2-master\default.py", line 569, in run
    u = urllib2.urlopen(self.cmd_str, timeout=20)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 404, in open
    response = self._open(req, data)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 422, in _open
    '_open', req)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 1214, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 1187, in do_open
    r = h.getresponse(buffering=True)
  File "C:\Program Files (x86)\Kodi\system\python\Lib\httplib.py", line 1067, in getresponse
    response.begin()
  File "C:\Program Files (x86)\Kodi\system\python\Lib\httplib.py", line 409, in begin
    version, status, reason = self._read_status()
  File "C:\Program Files (x86)\Kodi\system\python\Lib\httplib.py", line 373, in _read_status
    raise BadStatusLine(line)
BadStatusLine: ''
find quote
KenV99 Offline
Senior Member
Posts: 265
Joined: Nov 2013
Reputation: 8
Post: #174
I uploaded another version. Same link as above.

It seems that BadStatusLine is raised when the received response is not understandable by the standard python httplib:
https://docs.python.org/2/library/httpli...StatusLine

So I am just catching and passing it as not an error.

So the question is are the lights responding as you want?
find quote
spambus Offline
Junior Member
Posts: 33
Joined: Aug 2013
Reputation: 0
Post: #175
There is no error now, but the url is not triggered somehow, nothing happens

also I noticed now, I had the notifications turned off, turned them on, but there are no notifications being shown now, maybe related to url's also not triggering?
(This post was last modified: 2014-12-10 22:09 by spambus.)
find quote
KenV99 Offline
Senior Member
Posts: 265
Joined: Nov 2013
Reputation: 8
Post: #176
I updated one last time, so please download and try again. If that doesn't work, you may need to look at how you have the 'server' setup to respond, since, as mentioned above, it is receiving an unknown status code in the header and that is causing the exception. Why only on Windows, I have no idea. Otherwise I am at a loss.
find quote
spambus Offline
Junior Member
Posts: 33
Joined: Aug 2013
Reputation: 0
Post: #177
Now less works, before you would get a confirmation or error window when trying test command, now there is no window, and no notifications and url's still don't work... Confused
find quote
KenV99 Offline
Senior Member
Posts: 265
Joined: Nov 2013
Reputation: 8
Post: #178
Really, each time I need the log.
find quote
KenV99 Offline
Senior Member
Posts: 265
Joined: Nov 2013
Reputation: 8
Post: #179
If you get around to it, I created a branch that uses requests2 instead of urllib2.
If you are not using 'install from zip' you may need to download and install script.module.requests2, although it should do it automatically.
If you try it out, please post back a log with either success or failure.

https://github.com/KenV99/service.xbmc.c...quests.zip
(This post was last modified: 2014-12-11 15:21 by KenV99.)
find quote
wrxtasy Offline
Fan
Posts: 562
Joined: Feb 2012
Reputation: 5
Location: Perth, Oz
Post: #180
Script Newbie here....

Is it possible with this Add-On - service to automatically Disable Hardware acceleration when entering the PVR / Live TV section of XBMC and turn it back on when exiting ?

It would work around a long standing issue of XBMC crashes on ATV1/Crystalbuntu when viewing mpeg2 Live TV with Hardware Acceleration enabled if this can be implemented.

a bit more playing around gives me this to work with:
CHD Acceleration:
Code:
On:
jsonrpc?request={"id":1,"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"videoplayer.usechd","value":true}}

Off:
jsonrpc?request={"id":1,"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"videoplayer.usechd","value":false}}

------------------------------------------------------------------------------------------------------

Great Success ! I've finally coded a worked around for this annoying issue, follow below: Smile

http://forum.osmc.tv/showthread.php?tid=16534
(This post was last modified: 2014-12-16 09:25 by wrxtasy.)
find quote
Post Reply