Win Help with script to send HTTP command to RedEye
#1
Hi All,

I have just started learning Python so I can create some scripts for a few devices around the house that can be triggered from different things in XBMC. Now keep in mind I am VERY new to programming, but I'm usually pretty quick to pick these kind of things up.

My first attempt is to get XBMC to send a HTTP command ("http://192.168.0.5:8080/redeye/rooms/0/activities/launch?activityId=200") to my Think Flood Redeye unit to run an activity. This one turns on the TV, receiver and selects the correct volume and surround setting for a movie via IR signals.

I have found a script on the net that I have modified, but when I start a video, it flashes up a CMD box and disappears (too quick to read it) without triggering the activity. Can someone point out where I have gone wrong with this script? I'm guessing its something to do with "wget --spider"??

I would like to start building on this one for other tasks, but cant seem to find where I have gone wrong (I've already started some of the Python Tutorials but that's going to take some time).

System details are:
Win 7 64bit
XBMC Frodo 12.2

Script:
----------------------------------------------------------------------------------------
import xbmc,xbmcgui
import subprocess,os

class MyPlayer(xbmc.Player) :

def __init__ (self):
xbmc.Player.__init__(self)

def onPlayBackStarted(self):
if xbmc.Player().isPlayingVideo():
os.system("wget --spider 'http://192.168.0.5:8080/redeye/rooms/0/activities/launch?activityId=200'")

player=MyPlayer()

VIDEO = 0

while(1):
if xbmc.Player().isPlaying():
if xbmc.Player().isPlayingVideo():
VIDEO = 1

else:
VIDEO = 0

xbmc.sleep(1000)
----------------------------------------------------------------------------------------
Reply
#2
Cant help with the code (except, I dont think W7 uses wget so the error probably says 'wget' is not recognized as an internal or external command, operable program or batch file.).

I recommend you have a look in the XBMC.log file to see more details of whats going on. Maybe switching on debugging in the XBMC settings before doing it will give more info as well.

I use Baretail to watch the XBMC.log updating live.

Also, can you format the code as it is in the actual script? Python is very fussy about proper indentation. That will show up as a script error in the log.
Reply
#3
(2013-10-15, 04:18)Karnagious Wrote: (except, I dont think W7 uses wget so the error probably says 'wget' is not recognized as an internal or external command, operable program or batch file.).

Nail on the head. I recorded my screen to see the frame before the window disappeared and it reads "'wget' is not recognized as an internal or external command, operable program or batch file."

Anyone able to help with the correct code to use here?
Reply
#4
Update - I managed to work out a way to get it working. Let me know if there is a better way to do things as I would like to start out with clean scripts rather then messy ways to get a result.

New code:
---------------------------------------------------------------------------------------------------------------
Code:
import time
import urllib2
import xbmc,xbmcgui
import subprocess,os

class MyPlayer(xbmc.Player) :

        def __init__ (self):
            xbmc.Player.__init__(self)

        def onPlayBackStarted(self):
            if xbmc.Player().isPlayingVideo():
                response = urllib2.urlopen('http://192.168.0.5:8080/redeye/rooms/0/activities/launch?activityId=200')
                time.sleep(15)
                response = urllib2.urlopen('http://192.168.0.5:8080/redeye/rooms/0/activities/launch?activityId=-1')

player=MyPlayer()

VIDEO = 0

while(1):
    if xbmc.Player().isPlaying():
      if xbmc.Player().isPlayingVideo():
        VIDEO = 1

      else:
        VIDEO = 0

    xbmc.sleep(1000)
---------------------------------------------------------------------------------------------------------------
Reply

Logout Mark Read Team Forum Stats Members Help
Help with script to send HTTP command to RedEye0