[mythtv-users] Simple perl/python script to query recorder status via services API

Jack Perveiler perveilerj at gmail.com
Mon Aug 11 19:56:07 UTC 2014


Thanks Bill,,

Yep, that looks similar to what I pieced together myself yesterday (except
I think I needed to use ET.fromstring() since urlopen() returns a string).
I think I have it working now, it would be nice if someone could confirm
the State == 0 -> Encoder is idle assumption though.

--Jack



On Mon, Aug 11, 2014 at 3:08 PM, Bill Meek <keemllib at gmail.com> wrote:

> On 08/10/2014 12:28 PM, Jack Perveiler wrote:
>
>> I'd like to write a python or perl script that uses the services api to
>> see
>> if my HDPVR is idle.  I've looked at the services API documentation on the
>> wiki and have a few questions:
>>
>> 1) Did someone write this script already? :)
>>
> ...
>
> Hi,
>
> Try something starting with this:
>
> #!/usr/bin/env python
>
> #
> # Parse a Services API response
> #
>
> import urllib2
> from xml.etree import cElementTree as ET
>
> GEL_URL='http://yourMBEhostnameHere:6544/Dvr/GetEncoderList'
>
> try:
>     gel_response = ET.parse(urllib2.urlopen(GEL_URL))
> except:
>     raise SystemExit('GetEncoderList failed, is the backend running?')
>
> for element in gel_response.findall('Encoders/Encoder'):
>     id = element.findtext('Id')
>     state = element.findtext('State')
>     print 'Id = {}, State = {}.'.format(id, state)
>
> --
> Bill
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-users
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20140811/e0f2814f/attachment.html>


More information about the mythtv-users mailing list