From e00411f7ad3e671c7ae9762ff61ac57f9e164dfd Mon Sep 17 00:00:00 2001 From: NovaXeros Date: Wed, 16 Apr 2014 20:04:14 +0100 Subject: [PATCH 1/4] Cleaned LMS error reporting. Even upon successful rescan, the code would throw a keyerror back. Not certain why, but LMS sends some really weird unicode JSON back as its result, unlike XBMC, so having response[0]['result'] will always throw back a keyerror. Removing the key, however, and just asking the return to find 'result' works fine. --- headphones/notifiers.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/headphones/notifiers.py b/headphones/notifiers.py index ff27077f..801b4a83 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -247,10 +247,10 @@ class LMS: self.hosts = headphones.LMS_HOST def _sendjson(self, host): - data = {'id': 1, 'method': 'slim.request', 'params': ["",["rescan"]]} #Had a lot of trouble with simplejson, but this works. + data = {'id': 1, 'method': 'slim.request', 'params': ["",["rescan"]]} data = simplejson.JSONEncoder().encode(data) - content = {'Content-Type': 'application/json', 'Content-Length': len(data)} + content = {'Content-Type': 'application/json'} req = urllib2.Request(host+'/jsonrpc.js', data, content) @@ -261,21 +261,15 @@ class LMS: return response = simplejson.JSONDecoder().decode(handle.read()) - server_result = simplejson.dumps(response) try: - return response[0]['result'] + return response['result'] except: - logger.warn('LMS returned error: %s' % response[0]['error']) + logger.warn('LMS returned error: %s' % response['error']) return def update(self): - - #Send the ["rescan"] command to an LMS server. - #Note that the command must be prefixed with the 'player' that the command is aimed at, - #But with this being a request for the server to update its library, the player is blank, so "" - - hosts = [x.strip() for x in self.hosts.split(',')] + hosts = [x.strip() for x in self.hosts.split(',')] for host in hosts: logger.info('Sending library rescan command to LMS @ '+host) From 0234f4dab957efb8afdcf1f0218c043ee0fb1b4c Mon Sep 17 00:00:00 2001 From: NovaXeros Date: Wed, 16 Apr 2014 20:06:19 +0100 Subject: [PATCH 2/4] Update notifiers.py --- headphones/notifiers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/notifiers.py b/headphones/notifiers.py index 801b4a83..dcc63803 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -247,7 +247,7 @@ class LMS: self.hosts = headphones.LMS_HOST def _sendjson(self, host): - data = {'id': 1, 'method': 'slim.request', 'params': ["",["rescan"]]} + data = {'id': 1, 'method': 'slim.request', 'params': ["",["rescan"]]} data = simplejson.JSONEncoder().encode(data) content = {'Content-Type': 'application/json'} From a1d0f14eb8ccca1b7482dd421b206d9e112a11c1 Mon Sep 17 00:00:00 2001 From: NovaXeros Date: Wed, 16 Apr 2014 20:13:12 +0100 Subject: [PATCH 3/4] Change LMS title in config options. Squeezebox is an old unused name, and LMS isn't very self-explanitory. --- data/interfaces/default/config.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 820e729d..0f4345ab 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -678,9 +678,9 @@
-

LMS

+

Logitech Media Server

- +
From c96b043a198574b1a28ad46f9ce32549bc73313c Mon Sep 17 00:00:00 2001 From: NovaXeros Date: Wed, 16 Apr 2014 21:01:14 +0100 Subject: [PATCH 4/4] Update notifiers.py --- headphones/notifiers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/headphones/notifiers.py b/headphones/notifiers.py index dcc63803..806535a8 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -269,7 +269,8 @@ class LMS: return def update(self): - hosts = [x.strip() for x in self.hosts.split(',')] + + hosts = [x.strip() for x in self.hosts.split(',')] for host in hosts: logger.info('Sending library rescan command to LMS @ '+host)