Fix Pushy device token and add logging

This commit is contained in:
JonnyWong16 2017-03-27 21:12:39 -07:00
parent bc5ce52236
commit c405f04e9c

View file

@ -678,6 +678,7 @@ class ANDROIDAPP(Notifier):
'body': body.encode("utf-8")} 'body': body.encode("utf-8")}
} }
logger.debug(u"PlexPy Notifiers :: Pushy request body: %s" % json.dumps(data))
http_handler = HTTPSConnection("api.pushy.me") http_handler = HTTPSConnection("api.pushy.me")
http_handler.request("POST", http_handler.request("POST",
"/push?%s" % urlencode({'api_key': self.config['api_key']}), "/push?%s" % urlencode({'api_key': self.config['api_key']}),
@ -685,6 +686,7 @@ class ANDROIDAPP(Notifier):
body=json.dumps(data)) body=json.dumps(data))
response = http_handler.getresponse() response = http_handler.getresponse()
request_status = response.status request_status = response.status
logger.debug(u"PlexPy Notifiers :: Pushy response: %s" % response.read())
if request_status == 200: if request_status == 200:
logger.info(u"PlexPy Notifiers :: Android app notification sent.") logger.info(u"PlexPy Notifiers :: Android app notification sent.")
@ -709,9 +711,9 @@ class ANDROIDAPP(Notifier):
devices = {} devices = {}
for device in result: for device in result:
if device['friendly_name']: if device['friendly_name']:
devices['device_token'] = device['friendly_name'] devices[device['device_token']] = device['friendly_name']
else: else:
devices['device_token'] = device['device_name'] devices[device['device_token']] = device['device_name']
return devices return devices