[mythtv-users] New Sky+ App - control Sky box via tcp/ip network

Michael Watson michael at thewatsonfamily.id.au
Fri Dec 14 13:15:39 UTC 2012


The difference I see in the envelope is;

Sent by Poster:
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

Sent by Python: (Notice that this is split onto two lines)

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

Try this;

#!/usr/bin/env python
import  httplib,  sys

if len(sys.argv) < 3:
     sys.exit('Usage: %s <ipaddress/hostname> <channel> ' % sys.argv[0])

skyAddress = sys.argv[1]
channel = sys.argv[2]

conn=httplib.HTTP("%s:49153" % skyAddress)

XML="""<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:SetAVTransportURI xmlns:u="urn:schemas-nds-com:service:SkyPlay:2">
<InstanceID>0</InstanceID>
<CurrentURI>xsi://%s</CurrentURI>
<CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData>
</u:SetAVTransportURI>
</s:Body>
</s:Envelope>""" % channel

print len(XML)
conn.putrequest("POST", "/SkyPlay2")
conn.putheader("Host", "%s:49153" % skyAddress)
conn.putheader("User-Agent", "Channel Changer")
conn.putheader("Content-type", "text/xml; charset=\"UTF-8\"")
conn.putheader("Content-length", "%d" % len(XML))
conn.endheaders()
conn.send(XML)

response=  conn.getresponse()
print  response.status,  response.reason
print  response.read()
conn.close()

> Hi Michael,
>
> Thanks very much for your help with this.
>
> This is what nettool recorded when I used Poster:
>
> POST /SkyPlay2 HTTP/1.1
> Host: 192.168.1.250:49153
> User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language: en-US,en;q=0.5
> Accept-Encoding: gzip, deflate
> Connection: keep-alive
> SOAPACTION: "urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI"
> Content-Type: text/xml; charset=UTF-8
> Content-Length: 408
> Cookie: __utma=78958164.946757379.1354785368.1354785368.1354785368.4; __utmz=78958164.1354785368.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); SESSION-GUID=m8v9lrxfpks; __jwpusr=c461999f-789b-4497-b8b5-d894df56d717
> Pragma: no-cache
> Cache-Control: no-cache
>
> <?xml version="1.0" encoding="utf-8"?>
> <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
> <s:Body>
> <u:SetAVTransportURI xmlns:u="urn:schemas-nds-com:service:SkyPlay:2">
> <InstanceID>0</InstanceID>
> <CurrentURI>xsi://9c7</CurrentURI>
> <CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData>
> </u:SetAVTransportURI>
> </s:Body>
> </s:Envelope>
>
>
>
> This is what nettool recorded when I used your python script
>
> POST /SkyPlay2 HTTP/1.1
> Host: 192.168.1.250:49153
> Accept-Encoding: identity
> SOAPACTION: urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI
> Content-Length: 409
> Content-Type: text/xml; char-set=utf-8
>
> <?xml version="1.0" encoding="utf-8"?>
> <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
> <s:Body>
> <u:SetAVTransportURI xmlns:u="urn:schemas-nds-com:service:SkyPlay:2">
> <InstanceID>0</InstanceID>
> <CurrentURI>xsi://fa6</CurrentURI>
> <CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData>
> </u:SetAVTransportURI>
> </s:Body>
> </s:Envelope>
>
> As you can see, the two conversations are different, I'm pretty sure that, even with my limited knowledge of python, once we can get the channel change part working correctly, I can do the rest to accept the channel number as input and then use a lookup table to get the correct hex code to send to the Sky box. I think I'll even be able to interrogate the box to find out what channel it is on before and after the script runs (which is important, because there is an error generated if I try to switch to the channel it's already on.
>
> Regards,
> Dave.



More information about the mythtv-users mailing list