Updated htspmon debug script to receive EPG info.

This commit is contained in:
Adam Sutton 2012-09-15 11:01:30 +01:00
parent c2b967fbc4
commit a0b141adc6
2 changed files with 18 additions and 10 deletions

View file

@ -29,7 +29,7 @@ import log
# HTSP Client
# ###########################################################################
HTSP_PROTO_VERSION = 5
HTSP_PROTO_VERSION = 6
# Create passwd digest
def htsp_digest ( user, passwd, chal ):
@ -76,10 +76,9 @@ class HTSPClient:
self.send('hello', args)
resp = self.recv()
# Validate
if resp['htspversion'] != HTSP_PROTO_VERSION:
raise Exception('version mismatch')
self._auth = resp['challenge']
# Store
self._version = min(HTSP_PROTO_VERSION, resp['htspversion'])
self._auth = resp['challenge']
# Return response
return resp
@ -95,8 +94,8 @@ class HTSPClient:
raise Exception('Authentication failed')
# Enable async receive
def enableAsyncMetadata ( self ):
self.send('enableAsyncMetadata')
def enableAsyncMetadata ( self, args = {} ):
self.send('enableAsyncMetadata', args)
# ############################################################################
# Editor Configuration

View file

@ -25,7 +25,6 @@ from optparse import OptionParser
# System path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'lib', 'py'))
import tvh
print sys.path
# TVH imports
from tvh.htsp import HTSPClient
@ -35,7 +34,7 @@ try:
# Command line
optp = OptionParser()
optp.add_option('-t', '--host', default='localhost',
optp.add_option('-a', '--host', default='localhost',
help='Specify HTSP server hostname')
optp.add_option('-o', '--port', default=9982, type='int',
help='Specify HTSP server port')
@ -43,12 +42,17 @@ try:
help='Specify HTSP authentication username')
optp.add_option('-p', '--passwd', default=None,
help='Specify HTSP authentication password')
optp.add_option('-e', '--epg', default=False, action='store_true',
help='Get async EPG updates')
optp.add_option('-t', '--update', default=None, type='int',
help='Specify when to receive updates from')
(opts, args) = optp.parse_args()
# Connect
htsp = HTSPClient((opts.host, opts.port))
msg = htsp.hello()
log.info('connected to %s [%s]' % (msg['servername'], msg['serverversion']))
log.info('using protocol v%d' % htsp._version)
# Authenticate
if opts.user:
@ -56,7 +60,12 @@ try:
log.info('authenticated as %s' % opts.user)
# Enable async
htsp.enableAsyncMetadata()
args = {}
if opts.epg:
args['epg'] = 1
if opts.update != None:
args['lastUpdate'] = opts.update
htsp.enableAsyncMetadata(args)
log.info('enabled async data')
# Process messages