mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 07:22:37 -07:00
Test all Plex mobile app triggers
This commit is contained in:
parent
a6cd512ebf
commit
0afd77fb2f
1 changed files with 26 additions and 9 deletions
|
@ -2622,24 +2622,29 @@ class PLEXMOBILEAPP(Notifier):
|
||||||
self.configurations = {
|
self.configurations = {
|
||||||
'created': {'group': 'media', 'identifier': 'tv.plex.notification.library.new'},
|
'created': {'group': 'media', 'identifier': 'tv.plex.notification.library.new'},
|
||||||
'play': {'group': 'media', 'identifier': 'tv.plex.notification.playback.started'},
|
'play': {'group': 'media', 'identifier': 'tv.plex.notification.playback.started'},
|
||||||
'newdevice': {'group': 'admin', 'identifier': 'tv.plex.notification.device.new'},
|
'newdevice': {'group': 'admin', 'identifier': 'tv.plex.notification.device.new'}
|
||||||
'test': {'group': 'media', 'identifier': 'tv.plex.notification.library.new'}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||||
if action not in self.configurations:
|
if action not in self.configurations and not action.startswith('test'):
|
||||||
logger.error(u"Tautulli Notifiers :: Notification action %s not allowed for %s." % (action, self.NAME))
|
logger.error(u"Tautulli Notifiers :: Notification action %s not allowed for %s." % (action, self.NAME))
|
||||||
return
|
return
|
||||||
|
|
||||||
headers = {'X-Plex-Token': plexpy.CONFIG.PMS_TOKEN}
|
if action == 'test':
|
||||||
|
tests = []
|
||||||
|
for configuration in self.configurations:
|
||||||
|
tests.append(self.agent_notify(subject=subject, body=body, action='test_'+configuration))
|
||||||
|
return all(tests)
|
||||||
|
|
||||||
|
configuration_action = action.split('test_')[-1]
|
||||||
|
|
||||||
# No subject to always show up regardless of client selected filters
|
# No subject to always show up regardless of client selected filters
|
||||||
# icon can be info, warning, or error
|
# icon can be info, warning, or error
|
||||||
# play = true to start playing when tapping the notification
|
# play = true to start playing when tapping the notification
|
||||||
# Send the minimal amount of data necessary through Plex servers
|
# Send the minimal amount of data necessary through Plex servers
|
||||||
data = {
|
data = {
|
||||||
'group': self.configurations[action]['group'],
|
'group': self.configurations[configuration_action]['group'],
|
||||||
'identifier': self.configurations[action]['identifier'],
|
'identifier': self.configurations[configuration_action]['identifier'],
|
||||||
'to': self.config['user_ids'],
|
'to': self.config['user_ids'],
|
||||||
'data': {
|
'data': {
|
||||||
'provider': {
|
'provider': {
|
||||||
|
@ -2649,9 +2654,18 @@ class PLEXMOBILEAPP(Notifier):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pretty_metadata = PrettyMetadata(kwargs['parameters'])
|
pretty_metadata = PrettyMetadata(kwargs.get('parameters'))
|
||||||
|
|
||||||
if action == 'test':
|
if action.startswith('test'):
|
||||||
|
data['data']['player'] = {
|
||||||
|
'title': 'Device',
|
||||||
|
'platform': 'Platform',
|
||||||
|
'machineIdentifier': 'Tautulli'
|
||||||
|
}
|
||||||
|
data['data']['user'] = {
|
||||||
|
'title': 'User',
|
||||||
|
'id': 0
|
||||||
|
}
|
||||||
data['metadata'] = {
|
data['metadata'] = {
|
||||||
'type': 'movie',
|
'type': 'movie',
|
||||||
'title': subject,
|
'title': subject,
|
||||||
|
@ -2675,9 +2689,10 @@ class PLEXMOBILEAPP(Notifier):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
logger.error(u"Tautulli Notifiers :: Notification action %s not supported for %s." % (action, self.NAME))
|
||||||
return
|
return
|
||||||
|
|
||||||
if data['group'] == 'media' and action != 'test':
|
if data['group'] == 'media' and not action.startswith('test'):
|
||||||
media_type = pretty_metadata.media_type
|
media_type = pretty_metadata.media_type
|
||||||
uri_rating_key = None
|
uri_rating_key = None
|
||||||
|
|
||||||
|
@ -2740,6 +2755,8 @@ class PLEXMOBILEAPP(Notifier):
|
||||||
)
|
)
|
||||||
data['play'] = self.config['tap_action'] == 'play'
|
data['play'] = self.config['tap_action'] == 'play'
|
||||||
|
|
||||||
|
headers = {'X-Plex-Token': plexpy.CONFIG.PMS_TOKEN}
|
||||||
|
|
||||||
return self.make_request(self.NOTIFICATION_URL, headers=headers, json=data)
|
return self.make_request(self.NOTIFICATION_URL, headers=headers, json=data)
|
||||||
|
|
||||||
def get_users(self):
|
def get_users(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue