XBMC: properly check if host is local
And added option to scan if remote
This commit is contained in:
1 parent
564a27461d
commit
0492e90d6f
2 files changed
+16
-4
No files matched your search
@@ -38,6 +38,14 @@ config = [{
|
|||||||
'advanced': True,
|
'advanced': True,
|
||||||
'description': 'Only update the first host when movie snatched, useful for synced XBMC',
|
'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',
|
'name': 'on_snatch',
|
||||||
'default': 0,
|
'default': 0,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ log = CPLog(__name__)
|
|||||||
|
|
||||||
class XBMC(Notification):
|
class XBMC(Notification):
|
||||||
|
|
||||||
listen_to = ['renamer.after']
|
listen_to = ['renamer.after', 'movie.snatched']
|
||||||
use_json_notifications = {}
|
use_json_notifications = {}
|
||||||
http_time_between_calls = 0
|
http_time_between_calls = 0
|
||||||
|
|
||||||
@@ -33,15 +33,19 @@ class XBMC(Notification):
|
|||||||
('GUI.ShowNotification', {'title': self.default_title, 'message': message, 'image': self.getNotificationImage('small')}),
|
('GUI.ShowNotification', {'title': self.default_title, 'message': message, 'image': self.getNotificationImage('small')}),
|
||||||
]
|
]
|
||||||
|
|
||||||
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):
|
||||||
calls.append(('VideoLibrary.Scan', {'directory': data.get('destination_dir', None)} if 'localhost' in host else {}))
|
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)
|
max_successful += len(calls)
|
||||||
response = self.request(host, calls)
|
response = self.request(host, calls)
|
||||||
else:
|
else:
|
||||||
response = self.notifyXBMCnoJSON(host, {'title':self.default_title, 'message':message})
|
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', {})])
|
response += self.request(host, [('VideoLibrary.Scan', {})])
|
||||||
max_successful += 1
|
max_successful += 1
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user