Add value3 to IFTTT notifications (Closes #1279)

This commit is contained in:
JonnyWong16 2018-03-16 09:45:30 -07:00
parent b505286caf
commit 8407f27fed

View file

@ -54,6 +54,7 @@ import twitter
import pynma
import plexpy
import common
import database
import helpers
import logger
@ -729,6 +730,13 @@ class PrettyMetadata(object):
def get_plex_url(self):
return self.parameters['plex_url']
@staticmethod
def get_parameters():
parameters = {param['value']: param['name']
for category in common.NOTIFICATION_PARAMETERS for param in category['parameters']}
parameters[''] = ''
return parameters
class Notifier(object):
NAME = ''
@ -1943,7 +1951,8 @@ class IFTTT(Notifier):
"""
NAME = 'IFTTT'
_DEFAULT_CONFIG = {'key': '',
'event': 'tautulli'
'event': 'tautulli',
'value3': '',
}
def agent_notify(self, subject='', body='', action='', **kwargs):
@ -1952,6 +1961,10 @@ class IFTTT(Notifier):
data = {'value1': subject.encode("utf-8"),
'value2': body.encode("utf-8")}
if self.config['value3']:
pretty_metadata = PrettyMetadata(kwargs['parameters'])
data['value3'] = pretty_metadata.parameters.get(self.config['value3'], '')
headers = {'Content-type': 'application/json'}
return self.make_request('https://maker.ifttt.com/trigger/{}/with/key/{}'.format(event, self.config['key']),
@ -1975,6 +1988,13 @@ class IFTTT(Notifier):
' as <span class="inline-pre">value1</span>'
' and <span class="inline-pre">value2</span> respectively.',
'input_type': 'text'
},
{'label': 'Value 3',
'value': self.config['value3'],
'name': 'ifttt_value3',
'description': 'Optional: Select a parameter to send as <span class="inline-pre">value3</span>.',
'input_type': 'select',
'select_options': PrettyMetadata().get_parameters()
}
]