From b9d924db2f92fcf2226f02041746da6e9a71aaef Mon Sep 17 00:00:00 2001 From: William McBrine Date: Fri, 30 May 2014 10:26:22 -0400 Subject: [PATCH] Use Zeroconf-specified base path for ToGo, instead of a hardwired one. --- beacon.py | 1 + plugins/togo/togo.py | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/beacon.py b/beacon.py index aebe853..ae604fa 100644 --- a/beacon.py +++ b/beacon.py @@ -86,6 +86,7 @@ class ZCBroadcast: port = info.getPort() config.tivos[tsn] = {'name': name, 'address': address, 'port': port} + config.tivos[tsn].update(info.properties) self.logger.info(name) return names diff --git a/plugins/togo/togo.py b/plugins/togo/togo.py index 0311f57..8dbda07 100644 --- a/plugins/togo/togo.py +++ b/plugins/togo/togo.py @@ -28,6 +28,10 @@ CLASS_NAME = 'ToGo' BADCHAR = {'\\': '-', '/': '-', ':': ' -', ';': ',', '*': '.', '?': '.', '!': '.', '"': "'", '<': '(', '>': ')', '|': ' '} +# Default top-level share path + +DEFPATH = '/TiVoConnect?Command=QueryContainer&Container=/NowPlaying' + # Some error/status message templates MISSING = """

Missing Data

You must set both "tivo_mak" and @@ -105,18 +109,18 @@ class ToGo(Plugin): if 'TiVo' in query: tivoIP = query['TiVo'][0] tsn = config.tivos_by_ip(tivoIP) - tivo_name = config.tivos[tsn].get('name', tivoIP) + attrs = config.tivos[tsn] + tivo_name = attrs.get('name', tivoIP) tivo_mak = config.get_tsn('tivo_mak', tsn) - if 'port' in config.tivos[tsn]: - ip_port = '%s:%d' % (tivoIP, config.tivos[tsn]['port']) - else: - ip_port = tivoIP - theurl = ('https://' + ip_port + - '/TiVoConnect?Command=QueryContainer&ItemCount=' + - str(shows_per_page) + '&Container=/NowPlaying') + + protocol = attrs.get('protocol', 'https') + ip_port = '%s:%d' % (tivoIP, attrs.get('port', 443)) + path = attrs.get('path', DEFPATH) if 'Folder' in query: - folder += query['Folder'][0] - theurl += '/' + folder + folder = query['Folder'][0] + path += '/' + folder + theurl = '%s://%s%s&ItemCount=%d' % (protocol, ip_port, + path, shows_per_page) if 'AnchorItem' in query: theurl += '&AnchorItem=' + quote(query['AnchorItem'][0]) if 'AnchorOffset' in query: -- 2.11.4.GIT