diff --git a/data/interfaces/default/css/plexpy.css b/data/interfaces/default/css/plexpy.css index 17cdfd68..c151142f 100644 --- a/data/interfaces/default/css/plexpy.css +++ b/data/interfaces/default/css/plexpy.css @@ -526,6 +526,12 @@ textarea.form-control:focus { text-align: center; pointer-events: none; } +.form-control[readonly] { + background-color: #555; +} +.form-control[readonly]:focus { + background-color: #fff; +} .poster { position: relative; height: 225px; @@ -3037,12 +3043,6 @@ a:hover .overlay-refresh-image:hover { #plex-log-levels label { margin-bottom: 0; } -#api_key.form-control[readonly] { - background-color: #555; -} -#api_key.form-control[readonly]:focus { - background-color: #fff; -} #plexpy-notifiers-table .friendly_name, #notifier-config-modal span.notifier_id { color: #777; diff --git a/data/interfaces/default/notifier_config.html b/data/interfaces/default/notifier_config.html index 4cb74836..1e2723b9 100644 --- a/data/interfaces/default/notifier_config.html +++ b/data/interfaces/default/notifier_config.html @@ -43,7 +43,7 @@
- + % if item['name'] == 'osx_notify_app': Register % endif diff --git a/plexpy/api2.py b/plexpy/api2.py index c2a7f5e9..72c01399 100644 --- a/plexpy/api2.py +++ b/plexpy/api2.py @@ -341,13 +341,13 @@ class API2: return data - def register_android_app(self, notifier_id=None, device_id='', **kwargs): + def register_android_app(self, notifier_id=None, device_token='', **kwargs): """ Registers the PlexPy Android App for notifications. ``` Required parameters: notifier_id (int): The notifier id of the PlexPy Android App notifier - device_id (str): The device id of the PlexPy Android App + device_token (str): The device token of the PlexPy Android App Optional parameters: None @@ -363,8 +363,8 @@ class API2: self._api_result_type = 'error' return - elif not device_id: - self._api_msg = 'Device registartion failed: no device id provided.' + elif not device_token: + self._api_msg = 'Device registartion failed: no device token provided.' self._api_result_type = 'error' return @@ -375,8 +375,8 @@ class API2: self._api_result_type = 'error' return - config = {'androidapp_apikey': notifier['config']['apikey'], - 'androidapp_deviceid': device_id} + config = {'androidapp_api_key': notifier['config']['api_key'], + 'androidapp_device_token': device_token} if notifiers.set_notifier_config(notifier_id=notifier_id, agent_id=notifier['agent_id'], **config): self._api_msg = 'Device registration successful.' diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index 2e9a911a..83f94844 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -665,32 +665,23 @@ class ANDROIDAPP(Notifier): """ PlexPy Android App notifications """ - _DEFAULT_CONFIG = {'apikey': '', - 'deviceid': '' + _DEFAULT_CONFIG = {'api_key': '', + 'device_token': '' } - def _register_device(self, apikey='', device_id=''): - config = {'apikey': apikey, - 'deviceid': device_id} - - if self.set_config(config): - return True - def notify(self, subject='', body='', action='', **kwargs): if not subject or not body: return - data = {'to': self.config['deviceid'], + data = {'to': self.config['device_token'], 'data': {'subject': subject.encode("utf-8"), 'body': body.encode("utf-8")} } http_handler = HTTPSConnection("api.pushy.me") http_handler.request("POST", - "/push", - headers={ - 'Content-type': "application/json" - }, + "/push?%s" % urlencode({'api_key': self.config['api_key']}), + headers={'Content-type': "application/json"}, body=json.dumps(data)) response = http_handler.getresponse() request_status = response.status @@ -707,10 +698,17 @@ class ANDROIDAPP(Notifier): def return_config_options(self): config_option = [{'label': 'Pushy API Key', - 'value': self.config['apikey'], - 'name': 'androidapp_apikey', + 'value': self.config['api_key'], + 'name': 'androidapp_api_key', 'description': 'Your Pushy API key.', 'input_type': 'text' + }, + {'label': 'Device Token', + 'value': self.config['device_token'], + 'name': 'androidapp_device_token', + 'description': 'Your Android App device token. Filled in automatically after registering the deivce in the app.', + 'input_type': 'text', + 'readonly': True } ]