<!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 WebAccess 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>
<style type="text/css">
body
{
font-family: Arial, Verdana, Sans-Serif ! important;
font-size: 12px;
padding: 5px 5px 5px 5px;
margin: 0px;
border-style: none;
background-color: #ffffff;
}
p, ul, li
{
margin-top: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<blockquote style="border-left: 2px solid #325FBA; padding-left: 5px;margin-left:5px;">-----Original message-----<br /><strong>From:</strong>        Michael Watson <michael@thewatsonfamily.id.au><br /><strong>Sent:</strong>        Thu 13-12-2012 22:25<br /><strong>Subject:</strong>        Re: [mythtv-users] New Sky+ App - control Sky box via tcp/ip network<br /><strong>To:</strong>        Discussion about MythTV <mythtv-users@mythtv.org>; <br />On 14/12/2012 1:44 AM, Dave Pearson wrote:<br />> RE: [mythtv-users] New Sky+ App - control Sky box via tcp/ip network<br />><br />> -----Original message-----<br />> *From:* Michael Watson <michael@thewatsonfamily.id.au><br />> *Sent:* Thu 13-12-2012 04:08<br />> *Subject:* Re: [mythtv-users] New Sky+ App - control Sky box via<br />> tcp/ip network<br />> *To:* Discussion about MythTV <mythtv-users@mythtv.org>;<br />> On 13/12/2012 1:41 PM, Nick Rout wrote:<br />> ><br />> ><br />> > On Thu, Dec 13, 2012 at 10:29 AM, Dave Pearson<br />> > <lists@the-pearsons.co.uk <mailto:lists@the-pearsons.co.uk>> wrote:<br />> ><br />> > -----Original message-----<br />> > *From:* Raymond Wagner <raymond@wagnerrp.com<br />> > <mailto:raymond@wagnerrp.com>><br />> > *Sent:* Thu 16-08-2012 21:14<br />> > *Subject:* Re: [mythtv-users] New Sky+ App - control Sky box<br />> > via tcp/ip network<br />> > *To:* Discussion about MythTV <mythtv-users@mythtv.org<br />> > <mailto:mythtv-users@mythtv.org>>;<br />> > On 8/16/2012 10:38, Dave Pearson wrote:<br />> > > Before anyone says why don't I do it myself - I'm not<br />> clever<br />> > enough!<br />> ><br />> > Sure you are, you just don't know you are. Grab a copy of<br />> > wireshark or<br />> > tcpdump and have at it. Just start it up, and record the<br />> > communications<br />> > between the iPad and the STB as you perform various actions.<br />> > The only<br />> > real difficulty would be if they decided it was necessary to<br />> > perform<br />> > some kind of authentication between the STB and application,<br />> > or worse,<br />> > encrypted the communication.<br />> > _______________________________________________<br />> > mythtv-users mailing list<br />> > mythtv-users@mythtv.org <mailto:mythtv-users@mythtv.org><br />> > http://www.mythtv.org/mailman/listinfo/mythtv-users<br />> ><br />> > OK, I wasn't clever enough to use wireshark to figure out how to<br />> > send the control commands to my SKY+HD Box, but someone else was<br />> ><br />> (http://www.gladdy.co.uk/blog/2012/08/21/the-skyhd-picasso-dnla-control-server-protocol/)<br />> > and using the information on that page I have been able to use<br />> > firefox poster to send a command to change the channel. I'm now<br />> > trying to take what I'm using in poster to create a bash script<br />> > that I can use to change the channel in mythtv,<br />> unfortunately I'm<br />> > having no luck with curl at all.<br />> ><br />> > This is what I'm POSTing using poster:<br />> ><br />> > headers:<br />> ><br />> > SOAPACTION:<br />> urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI<br />> ><br />> > content-type: text/xml; charset=utf-8<br />> ><br />> > body:<br />> ><br />> > <?xml version="1.0" encoding="utf-8"?><br />> ><br />> > <s:Envelope<br />> > s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"<br />> > xmlns:s="http://schemas.smlsoap.org/soap/envelope/"><br />> ><br />> > <s:Body><br />> ><br />> > <u:SetAVTransportURI<br />> xmlns:u="urn:schemas-nds-com:service:SkyPlay:2"><br />> ><br />> > <InstanceID>0</InstanceID><br />> ><br />> > <CurrentURI>xsi://ff0</CurrentURI><br />> ><br />> > <CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData><br />> ><br />> > </u:SetAVTransportURI><br />> ><br />> > </s:Body><br />> ><br />> > </s:Envelope><br />> ><br />> > Using the above code in poster I mange to change the channel to<br />> > ff0, which is the hex code for channel 113 (Universal HD),<br />> > unfortunately I just cannot figure out how I can get curl to<br />> POST<br />> > the body text (I think the headers are being passed<br />> correctly. I'm<br />> > sure this is really simple, but I'm just stuck! any help will be<br />> > gratefully received.<br />> ><br />> > Regards,<br />> ><br />> > Dave<br />> ><br />> ><br />> > can wget do this?<br />> ><br />> Possibly, but might be easier to use something like python or<br />> perl, as<br />> then end result is going to be a channel change script I guess.<br />> This python code might do the trick.<br />><br />><br />> import httplib, urllib<br />> import re<br />><br />> conn= httplib.HTTPConnection("http://xxx.xxx.xxx.xx<br />> <http://xxx.xxx.xxx.xx/>:49153/SkyPlay2")<br />> XML='*****XMLSTUFF Goes Here *****'<br />> headers= { "SOAPACTION:<br />> urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI",<br />> "content-type: text/xml", "charset=utf-8"}<br />> conn.request("POST", params, "", headers)<br />> conn.send(XML)<br />> response= conn.getresponse()<br />> print response.status, response.reason<br />><br />> print response.read()<br />> conn.close()<br />><br />><br />><br />> _______________________________________________<br />> mythtv-users mailing list<br />> mythtv-users@mythtv.org<br />> http://www.mythtv.org/mailman/listinfo/mythtv-users<br />><br />> Thanks for your suggestion, unfortunately I don'y know python at all, <br />> so cannot really debug where it's going wrong.<br />><br />> Perhaps it might help if I post the curl command that I am using:<br />><br />> curl --verbose --header "Content-Type: text/xml" --header "SOAPACTION: <br />> urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI" -d <br />> @posterbody.xml -X POST http://192.168.1.202:49153/SkyPlay2<br />><br />> and the contents of posterbody.xml:<br />><br />> <?xml version="1.0" encoding="utf-8"?><br />> <s:Envelope <br />> s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" <br />> xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><br />> <s:Body><br />> <u:SetAVTransportURI xmlns:u="urn:schemas-nds-com:service:SkyPlay:2"><br />> <InstanceID>0</InstanceID><br />> <CurrentURI>xsi://ff0</CurrentURI><br />> <CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData><br />> </u:SetAVTransportURI><br />> </s:Body><br />> </s:Envelope><br />><br />> and this is what I get in return:<br />><br />> * About to connect() to 192.168.1.202 port 49153 (#0)<br />> * Trying 192.168.1.202...<br />> * connected<br />> * Connected to 192.168.1.202 (192.168.1.202) port 49153 (#0)<br />> > POST /SkyPlay2 HTTP/1.1<br />> > User-Agent: curl/7.27.0<br />> > Host: 192.168.1.202:49153<br />> > Accept: */*<br />> > Content-Type: text/xml<br />> > SOAPACTION: urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI<br />> > Content-Length: 399<br />> ><br />> * upload completely sent off: 399 out of 399 bytes<br />> * additional stuff not fine transfer.c:1037: 0 0<br />> * HTTP 1.1 or later with persistent connection, pipelining supported<br />> < HTTP/1.1 500 Internal Server Error<br />> < CONTENT-LENGTH: 413<br />> < CONTENT-TYPE: text/xml; charset="utf-8"<br />> < DATE: Sat, 05 Feb 2000 12:25:32 GMT<br />> < EXT:<br />> < SERVER: Linux/2.6.18.8 UPnP/1.0 SKY DLNADOC/1.50<br />> < X-User-Agent: redsonic<br />> <<br />> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" <br />> s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><br />> <s:Body><br />> <s:Fault><br />> <faultcode>s:Client</faultcode><br />> <faultstring>UPnPError</faultstring><br />> <detail><br />> <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><br />> <errorCode>-111</errorCode><br />> <errorDescription>Invalid Action</errorDescription><br />> </UPnPError><br />> </detail><br />> </s:Fault><br />> </s:Body><br />> </s:Envelope><br />> * Connection #0 to host 192.168.1.202 left intact<br />> * Closing connection #0<br />><br />> As I said before, this code works fine in firefox poster and correctly <br />> changes the channel (almost instantaneously, much much quicker than my <br />> IR script can do it and much more reliably too! Any help I can get to <br />> get this working will be very gratefully received.<br />><br />> Regards,<br />><br />> Dave.<br />><br />><br />Try this. You will need to run the script like "scriptname <br />192.168.1.202 ff0"<br /><br /><br />#!/usr/bin/env python<br /><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.HTTPConnection("%s:49153" % skyAddress)<br /><br />XML="""<?xml version="1.0" encoding="utf-8"?><br /><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" <br />xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><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 />headers= { "Content-Type": "text/xml", "SOAPACTION": <br />"urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI"}<br />conn.request("POST", "/SkyPlay2", "", headers)<br /><br />conn.send(XML)<br />response= conn.getresponse()<br /><br />print response.status, response.reason<br />print response.read()<br /><br />conn.close()<br /><br />_______________________________________________<br />mythtv-users mailing list<br />mythtv-users@mythtv.org<br />http://www.mythtv.org/mailman/listinfo/mythtv-users<br /></blockquote><p><br /> Still no joy, unfortunately, this is what I get when I try that script:</p><p> </p><p>python test 192.168.1.202 ff0</p><p>500 Internal Server Error</p><p><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></p><p><s:Body></p><p><s:Fault></p><p><faultcode>s:Client</faultcode></p><p><faultstring>UPnPError</faultstring></p><p><detail></p><p><UPnPError xmlns="urn:schemas-upnp-org:control-1-0"></p><p><errorCode>501</errorCode></p><p><errorDescription>XML error</errorDescription></p><p></UPnPError></p><p></detail></p><p></s:Fault></p><p></s:Body></p><p></s:Envelope></p><p> </p><p>regards,</p><p>Dave.</p>
</body>
</html>