From bdeace8a68b4acd0f4b5c8a54de0f33c692bbb15 Mon Sep 17 00:00:00 2001 From: Dean Gardiner Date: Sun, 13 Oct 2013 03:00:52 +1300 Subject: [PATCH] New clients added that aren't in the current client cache now trigger a reload if the list isn't "stale" yet. --- couchpotato/core/notifications/plex/main.py | 4 ++-- couchpotato/core/notifications/plex/server.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/notifications/plex/main.py b/couchpotato/core/notifications/plex/main.py index d3644d5..514b119 100755 --- a/couchpotato/core/notifications/plex/main.py +++ b/couchpotato/core/notifications/plex/main.py @@ -43,14 +43,14 @@ class Plex(Notification): client_success = False client = self.server.clients.get(client_name) - if client: + if client and client['found']: client_success = fireEvent('notify.plex.notifyClient', client, message, single=True) if client_success: client_names.pop(0) if not client_success: - if self.server.staleClients(): + if self.server.staleClients() or not client: log.info('Failed to send notification to client "%s". ' 'Client list is stale, updating the client list and retrying.', client_name) self.server.updateClients(self.getClientNames()) diff --git a/couchpotato/core/notifications/plex/server.py b/couchpotato/core/notifications/plex/server.py index 4df6e9b..b66db8f 100644 --- a/couchpotato/core/notifications/plex/server.py +++ b/couchpotato/core/notifications/plex/server.py @@ -58,11 +58,13 @@ class PlexServer(object): if c.get('name') and c.get('name').lower() in client_names ] + # Store client details in cache for client in found_clients: name = client.get('name').lower() self.clients[name] = { 'name': client.get('name'), + 'found': True, 'address': client.get('address'), 'port': client.get('port'), 'protocol': client.get('protocol', 'xbmchttp') @@ -70,6 +72,12 @@ class PlexServer(object): client_names.remove(name) + # Store dummy info for missing clients + for client_name in client_names: + self.clients[client_name] = { + 'found': False + } + if len(client_names) > 0: log.debug('Unable to find clients: %s', ', '.join(client_names))