[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)
(2015-03-03, 16:50)milhouse34521 Wrote: Can anyone help me with a modification to this script?

I'd like to call a URL rather than run a script when a video starts. The script sets certain features of my receiver based on the time of time, status of certain doors etc. Because I am using Windows, running a batch script pops up the command line, which is annoying. I know there are modificaitons that can be done, but I thought I'd try to modify the script. I know Python, but I am not that familiar with kodi add-ons.

Here is the function:
Code:
def onPlayBackStarted(self):
    log('player starts')
    # Chris's rewrite
    global script_player_starts
    if script_player_starts:
      log('Going to use urllib2 to set listening mode')
      #log('Going to execute script = "' + script_player_starts + '"')
      try:
          #subprocess.call([script_player_starts,self.playing_type()])
          response = urllib2.urlopen('http://raspberrypi/set_listening_mode.php')
          response = 'Response from server = ' + response
          log(response)
      except:
          log('ERROR executing script when player starts')

The error I get is from the exception. If I had to guess its because its not importing urllib2, but before I install it, I was wondering if anyone knew what the issue was for sure.

Thanks.

Can you change the code to show you the contents of the exception

Code:
except Exception, e:
    log(str(e))

But yes, if you're not importing urllib2 then attempting to use it will error
Reply


Messages In This Thread
Great! - by gnorf - 2013-02-27, 22:50
[RELEASE] Pilulli Revisited - by KenV99 - 2014-06-28, 18:18
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - by spoyser - 2015-03-03, 19:33
Logout Mark Read Team Forum Stats Members Help
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)4