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

Dave Pearson lists at the-pearsons.co.uk
Fri Dec 14 14:59:39 UTC 2012


-----Original message-----
> From:Michael Watson <michael at thewatsonfamily.id.au <mailto:michael at thewatsonfamily.id.au> >
> Sent: Friday 14th December 2012 13:52
> To: mythtv-users at mythtv.org <mailto:mythtv-users at mythtv.org> 
> Subject: Re: [mythtv-users] New Sky+ App - control Sky box via tcp/ip network
> 
> On 15/12/2012 12:37 AM, Dave Pearson wrote:
> > RE: [mythtv-users] New Sky+ App - control Sky box via tcp/ip network
> > -----Original message-----
> > > From:Michael Watson <michael at thewatsonfamily.id.au <mailto:michael at thewatsonfamily.id.au>   <mailto:michael at thewatsonfamily.id.au <mailto:michael at thewatsonfamily.id.au> >>
> > > Sent: Friday 14th December 2012 13:16
> > > To: Discussion about MythTV <mythtv-users at mythtv.org <mailto:mythtv-users at mythtv.org>   <mailto:mythtv-users at mythtv.org <mailto:mythtv-users at mythtv.org> >>
> > > Subject: Re: [mythtv-users] New Sky+ App - control Sky box via tcp/ip network
> > >
> > >
> > > The difference I see in the envelope is;
> > >
> > > Sent by Poster:
> > > <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding <http://schemas.xmlsoap.org/soap/encoding> /"
> > > xmlns:s="http://schemas.xmlsoap.org/soap/envelope <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 <http://schemas.xmlsoap.org/soap/encoding> /"
> > > xmlns:s="http://schemas.xmlsoap.org/soap/envelope <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 <http://schemas.xmlsoap.org/soap/encoding> /"
> > > xmlns:s="http://schemas.xmlsoap.org/soap/envelope <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 <http://schemas.xmlsoap.org/soap/encoding> /" xmlns:s="http://schemas.xmlsoap.org/soap/envelope <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 <http://schemas.xmlsoap.org/soap/encoding> /"
> > > > xmlns:s="http://schemas.xmlsoap.org/soap/envelope <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.
> > >
> > > _______________________________________________
> > > mythtv-users mailing list
> > >mythtv-users at mythtv.org <mailto:mythtv-users at mythtv.org>   <mailto:mythtv-users at mythtv.org <mailto:mythtv-users at mythtv.org> >
> > >http://www.mythtv.org/mailman/listinfo/mythtv-users <http://www.mythtv.org/mailman/listinfo/mythtv-users> 
> > >
> >
> > Hi Michael,
> >
> > I've cracked it!
> >
> > 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.
> >
> > 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).
> >
> > 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.
> >
> > Regards,
> > Dave.
> >
> Well done.
> Ive already done the channel lookup (from channel list found on 
> http://www.gladdy.co.uk/blog/2012/08/21/the-skyhd-picasso-dnla-control-server-protocol <http://www.gladdy.co.uk/blog/2012/08/21/the-skyhd-picasso-dnla-control-server-protocol> /
> I also adjusted the script to add the quotes.  All that needs to be done 
> is check the channel it is currently tuned to.  (A quick hack would be 
> to just ignore the error it returns when it is already on that channel)
> 
> 
> 
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org <mailto:mythtv-users at mythtv.org> 
> http://www.mythtv.org/mailman/listinfo/mythtv-users <http://www.mythtv.org/mailman/listinfo/mythtv-users> 
> 

Hi Michael,

That's fantastic - your script works perfectly (and I was having trouble getting my head round python - for some reason, even though I had set the channel variable to that it matched the correct hex code, I kept on creating an XML string that wanted to change the channel to FA1 - I just couldn't see what was setting it!, I may have had more joy if I had modified one of my php or bash efforts as I know those a little better).

I may add the checking code later, meanwhile I really should get on with some real work :-)

Thanks again for all of your help, I'm sure the could be many others who will make use of your script.

Regards,
Dave.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20121214/53601cbe/attachment-0001.html>


More information about the mythtv-users mailing list