[mythtv-users] How to check if a tuner is in use
Hika van den Hoven
hikavdh at gmail.com
Wed Oct 15 21:52:25 UTC 2014
Hoi Bill,
Wednesday, October 15, 2014, 10:53:13 PM, you wrote:
> As to you other question, more *endpoints* are documented here,
> although a bit out of data: http://www.mythtv.org/wiki/Services_API
Ah, then it becomes this! So far my first lesson in Python.
I do miss the end statements, but it's all done by position and I
already always worked that way, but still.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import argparse, socket, urllib2, sys
from urllib2 import urlopen
from xml.etree import cElementTree as ET
parser = argparse.ArgumentParser(description='Get Status of Backend Encoders.')
parser.add_argument('--card', type=str, required=False,
metavar='<device>', default='/dev/video0',
help='tv capture device, default </dev/video0>')
parser.add_argument('--host', type=str, required=False,
metavar='<hostname>', default=socket.gethostname(),
help='backend hostname, default <local hostname>')
args = parser.parse_args()
URL1 = 'http://{}:6544/Capture/GetCaptureCardList?HostName={}' \
.format(args.host, args.host)
URL2 = 'http://{}:6544/Dvr/GetEncoderList'.format(args.host)
try:
response = ET.parse(urlopen(URL1))
except:
raise SystemExit('GetCaptureCardList failed, is the backend running?')
for element1 in response.findall('CaptureCards/CaptureCard'):
if element1.findtext('VideoDevice') == args.card:
try:
response = ET.parse(urlopen(URL2))
except:
raise SystemExit('GetEncoderList failed, is the backend running?')
for element2 in response.findall('Encoders/Encoder'):
if element2.findtext('Id') == element1.findtext('CardId'):
sys.exit(int(element2.findtext('State')))
break
break
sys.exit(-1)
Tot mails,
Hika mailto:hikavdh at gmail.com
"Zonder hoop kun je niet leven
Zonder leven is er geen hoop
Het eeuwige dilemma
Zeker als je hoop moet vernietigen om te kunnen overleven!"
De lerende Mens
More information about the mythtv-users
mailing list