From 4ebbc1a01d8bda9f5b4435afbc936ec9ff6c992d Mon Sep 17 00:00:00 2001 From: mano3m <-> Date: Sun, 14 Jul 2013 02:19:35 +0200 Subject: [PATCH 1/3] XBMC: Only scan the new movie folder --- couchpotato/core/notifications/xbmc/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/notifications/xbmc/main.py b/couchpotato/core/notifications/xbmc/main.py index ad6fa605..b1ad57a1 100755 --- a/couchpotato/core/notifications/xbmc/main.py +++ b/couchpotato/core/notifications/xbmc/main.py @@ -34,7 +34,7 @@ class XBMC(Notification): ] if not self.conf('only_first') or hosts.index(host) == 0: - calls.append(('VideoLibrary.Scan', {})) + calls.append(('VideoLibrary.Scan', {'directory': data.get('destination_dir', None)})) max_successful += len(calls) response = self.request(host, calls) From 564a27461d6ab020c4bf83ea5101958d74febda2 Mon Sep 17 00:00:00 2001 From: mano3m <-> Date: Sun, 14 Jul 2013 23:30:37 +0200 Subject: [PATCH 2/3] XBMC: Only add directory if XBMC is on localhost --- couchpotato/core/notifications/xbmc/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/notifications/xbmc/main.py b/couchpotato/core/notifications/xbmc/main.py index b1ad57a1..7266b25c 100755 --- a/couchpotato/core/notifications/xbmc/main.py +++ b/couchpotato/core/notifications/xbmc/main.py @@ -34,7 +34,7 @@ class XBMC(Notification): ] if not self.conf('only_first') or hosts.index(host) == 0: - calls.append(('VideoLibrary.Scan', {'directory': data.get('destination_dir', None)})) + calls.append(('VideoLibrary.Scan', {'directory': data.get('destination_dir', None)} if 'localhost' in host else {})) max_successful += len(calls) response = self.request(host, calls) From 0492e90d6fdc76b97f505dcb851740d75187901d Mon Sep 17 00:00:00 2001 From: mano3m <-> Date: Tue, 16 Jul 2013 22:35:32 +0200 Subject: [PATCH 3/3] XBMC: properly check if host is local And added option to scan if remote --- couchpotato/core/notifications/xbmc/__init__.py | 8 ++++++++ couchpotato/core/notifications/xbmc/main.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/couchpotato/core/notifications/xbmc/__init__.py b/couchpotato/core/notifications/xbmc/__init__.py index e3c467ce..f0167ce8 100644 --- a/couchpotato/core/notifications/xbmc/__init__.py +++ b/couchpotato/core/notifications/xbmc/__init__.py @@ -38,6 +38,14 @@ config = [{ 'advanced': True, 'description': 'Only update the first host when movie snatched, useful for synced XBMC', }, + { + 'name': 'remote_dir_scan', + 'label': 'Remote Folder Scan', + 'default': 0, + 'type': 'bool', + 'advanced': True, + 'description': 'Scan new movie folder at remote XBMC servers, only works if movie location is the same.', + }, { 'name': 'on_snatch', 'default': 0, diff --git a/couchpotato/core/notifications/xbmc/main.py b/couchpotato/core/notifications/xbmc/main.py index 7266b25c..34a9c1da 100755 --- a/couchpotato/core/notifications/xbmc/main.py +++ b/couchpotato/core/notifications/xbmc/main.py @@ -13,7 +13,7 @@ log = CPLog(__name__) class XBMC(Notification): - listen_to = ['renamer.after'] + listen_to = ['renamer.after', 'movie.snatched'] use_json_notifications = {} http_time_between_calls = 0 @@ -33,15 +33,19 @@ class XBMC(Notification): ('GUI.ShowNotification', {'title': self.default_title, 'message': message, 'image': self.getNotificationImage('small')}), ] - if not self.conf('only_first') or hosts.index(host) == 0: - calls.append(('VideoLibrary.Scan', {'directory': data.get('destination_dir', None)} if 'localhost' in host else {})) + if data and data.get('destination_dir') and (not self.conf('only_first') or hosts.index(host) == 0): + param = {} + if self.conf('remote_dir_scan') or socket.getfqdn('localhost') == socket.getfqdn(host.split(':')[0]): + param = {'directory': data['destination_dir']} + + calls.append(('VideoLibrary.Scan', param)) max_successful += len(calls) response = self.request(host, calls) else: response = self.notifyXBMCnoJSON(host, {'title':self.default_title, 'message':message}) - if not self.conf('only_first') or hosts.index(host) == 0: + if data and data.get('destination_dir') and (not self.conf('only_first') or hosts.index(host) == 0): response += self.request(host, [('VideoLibrary.Scan', {})]) max_successful += 1