From 075b43a410869de33174ac3f35bc0e27a7b0e6c3 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Mon, 8 Apr 2013 18:45:49 -0400 Subject: [PATCH] Avoid duplicate share names with old-style announcements (though only if Zeroconf is also enabled). With this change, two pyTivos with the same share names no longer interfere. --- beacon.py | 2 ++ httpserver.py | 4 ++++ templates/root_container.tmpl | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/beacon.py b/beacon.py index b6dc937..3248d65 100644 --- a/beacon.py +++ b/beacon.py @@ -32,6 +32,7 @@ class ZCBroadcast: self.share_info = [] self.logger = logger self.rz = Zeroconf.Zeroconf() + self.renamed = {} old_titles = self.scan() address = inet_aton(config.get_ip()) port = int(config.getPort()) @@ -53,6 +54,7 @@ class ZCBroadcast: while title in old_titles: count += 1 title = '%s [%d]' % (section, count) + self.renamed[section] = title info = Zeroconf.ServiceInfo('_%s._tcp.local.' % tt, '%s._%s._tcp.local.' % (title, tt), address, port, 0, 0, desc) diff --git a/httpserver.py b/httpserver.py index 20ccd79..f7ce411 100644 --- a/httpserver.py +++ b/httpserver.py @@ -293,6 +293,10 @@ class TivoHTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler): t = Template(file=os.path.join(SCRIPTDIR, 'templates', 'root_container.tmpl'), filter=EncodeUnicode) + if self.server.beacon.bd: + t.renamed = self.server.beacon.bd.renamed + else: + t.renamed = {} t.containers = tsncontainers t.hostname = socket.gethostname() t.escape = escape diff --git a/templates/root_container.tmpl b/templates/root_container.tmpl index 0316293..cc40c58 100644 --- a/templates/root_container.tmpl +++ b/templates/root_container.tmpl @@ -8,9 +8,14 @@ #for $name, $details in $containers + #if $name in $renamed + #set $title = $renamed[name] + #else + #set $title = $name + #end if
- $escape($name) + $escape($title) $escape($details.content_type) x-container/folder
-- 2.11.4.GIT