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

Bill Meek keemllib at gmail.com
Mon Aug 11 19:08:07 UTC 2014


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


More information about the mythtv-users mailing list