<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta name="Generator" content="Zarafa WebApp v7.1.1-37812">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>RE: [mythtv-users] New Sky+ App - control Sky box via tcp/ip network</title>
</head>
<body>
<pre style="white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;" wrap=""><br>-----Original message-----<br>> From:Michael Watson <<a href="mailto:michael@thewatsonfamily.id.au">michael@thewatsonfamily.id.au</a>><br>> Sent: Friday 14th December 2012 13:16<br>> To: Discussion about MythTV <<a href="mailto:mythtv-users@mythtv.org">mythtv-users@mythtv.org</a>><br>> Subject: Re: [mythtv-users] New Sky+ App - control Sky box via tcp/ip network<br>> <br>> <br>> The difference I see in the envelope is;<br>> <br>> Sent by Poster:<br>> <s:Envelope s:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding" target="_blank">http://schemas.xmlsoap.org/soap/encoding</a>/" <br>> xmlns:s="<a href="http://schemas.xmlsoap.org/soap/envelope" target="_blank">http://schemas.xmlsoap.org/soap/envelope</a>/"><br>> <br>> Sent by Python: (Notice that this is split onto two lines)<br>> <br>> <s:Envelope s:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding" target="_blank">http://schemas.xmlsoap.org/soap/encoding</a>/"<br>> xmlns:s="<a href="http://schemas.xmlsoap.org/soap/envelope" target="_blank">http://schemas.xmlsoap.org/soap/envelope</a>/"><br>> <br>> Try this;<br>> <br>> #!/usr/bin/env python<br>> import httplib, sys<br>> <br>> if len(sys.argv) < 3:<br>> sys.exit('Usage: %s <ipaddress/hostname> <channel> ' % sys.argv[0])<br>> <br>> skyAddress = sys.argv[1]<br>> channel = sys.argv[2]<br>> <br>> conn=httplib.HTTP("%s:49153" % skyAddress)<br>> <br>> XML="""<?xml version="1.0" encoding="utf-8"?><br>> <s:Envelope s:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding" target="_blank">http://schemas.xmlsoap.org/soap/encoding</a>/" <br>> xmlns:s="<a href="http://schemas.xmlsoap.org/soap/envelope" target="_blank">http://schemas.xmlsoap.org/soap/envelope</a>/"><br>> <s:Body><br>> <u:SetAVTransportURI xmlns:u="urn:schemas-nds-com:service:SkyPlay:2"><br>> <InstanceID>0</InstanceID><br>> <CurrentURI>xsi://%s</CurrentURI><br>> <CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData><br>> </u:SetAVTransportURI><br>> </s:Body><br>> </s:Envelope>""" % channel<br>> <br>> print len(XML)<br>> conn.putrequest("POST", "/SkyPlay2")<br>> conn.putheader("Host", "%s:49153" % skyAddress)<br>> conn.putheader("User-Agent", "Channel Changer")<br>> conn.putheader("Content-type", "text/xml; charset=\"UTF-8\"")<br>> conn.putheader("Content-length", "%d" % len(XML))<br>> conn.endheaders()<br>> conn.send(XML)<br>> <br>> response= conn.getresponse()<br>> print response.status, response.reason<br>> print response.read()<br>> conn.close()<br>> <br>> > Hi Michael,<br>> ><br>> > Thanks very much for your help with this.<br>> ><br>> > This is what nettool recorded when I used Poster:<br>> ><br>> > POST /SkyPlay2 HTTP/1.1<br>> > Host: 192.168.1.250:49153<br>> > User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0<br>> > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>> > Accept-Language: en-US,en;q=0.5<br>> > Accept-Encoding: gzip, deflate<br>> > Connection: keep-alive<br>> > SOAPACTION: "urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI"<br>> > Content-Type: text/xml; charset=UTF-8<br>> > Content-Length: 408<br>> > 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<br>> > Pragma: no-cache<br>> > Cache-Control: no-cache<br>> ><br>> > <?xml version="1.0" encoding="utf-8"?><br>> > <s:Envelope s:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding" target="_blank">http://schemas.xmlsoap.org/soap/encoding</a>/" xmlns:s="<a href="http://schemas.xmlsoap.org/soap/envelope" target="_blank">http://schemas.xmlsoap.org/soap/envelope</a>/"><br>> > <s:Body><br>> > <u:SetAVTransportURI xmlns:u="urn:schemas-nds-com:service:SkyPlay:2"><br>> > <InstanceID>0</InstanceID><br>> > <CurrentURI>xsi://9c7</CurrentURI><br>> > <CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData><br>> > </u:SetAVTransportURI><br>> > </s:Body><br>> > </s:Envelope><br>> ><br>> ><br>> ><br>> > This is what nettool recorded when I used your python script<br>> ><br>> > POST /SkyPlay2 HTTP/1.1<br>> > Host: 192.168.1.250:49153<br>> > Accept-Encoding: identity<br>> > SOAPACTION: urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI<br>> > Content-Length: 409<br>> > Content-Type: text/xml; char-set=utf-8<br>> ><br>> > <?xml version="1.0" encoding="utf-8"?><br>> > <s:Envelope s:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding" target="_blank">http://schemas.xmlsoap.org/soap/encoding</a>/"<br>> > xmlns:s="<a href="http://schemas.xmlsoap.org/soap/envelope" target="_blank">http://schemas.xmlsoap.org/soap/envelope</a>/"><br>> > <s:Body><br>> > <u:SetAVTransportURI xmlns:u="urn:schemas-nds-com:service:SkyPlay:2"><br>> > <InstanceID>0</InstanceID><br>> > <CurrentURI>xsi://fa6</CurrentURI><br>> > <CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData><br>> > </u:SetAVTransportURI><br>> > </s:Body><br>> > </s:Envelope><br>> ><br>> > 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.<br>> ><br>> > Regards,<br>> > Dave.<br>> <br>> _______________________________________________<br>> mythtv-users mailing list<br>> <a href="mailto:mythtv-users@mythtv.org">mythtv-users@mythtv.org</a><br>> <a href="http://www.mythtv.org/mailman/listinfo/mythtv-users" target="_blank">http://www.mythtv.org/mailman/listinfo/mythtv-users</a><br>> <br><br>Hi Michael,<br><br>I've cracked it!<br><br>The problem was that the SOAPACTION header parameter needed to have quotes at each end of the string and the python script (and all the other attempts I tried) wasn't sending them. I've amended the script and now it works.<br><br>Now all I have to do is modify it to do the channel number to hex code look up (unfortunately it's not a case of just converting the channel number to hex).<br><br>Thanks again for all of your help. When I've finished the script I'll post it here for anyone else that wants to use it to control a SKY+HD box from mythtv.<br><br>Regards,<br>Dave.<br></pre>
</body>
</html>