Use Plex API to check remote access down

This commit is contained in:
Jonathan Wong 2015-11-21 09:43:21 -08:00
commit 013d957e47
4 changed files with 60 additions and 57 deletions

View file

@ -270,6 +270,22 @@ class PmsConnect(object):
return request
"""
Return account details.
Optional parameters: output_format { dict, json }
Output: array
"""
def get_account(self, output_format=''):
uri = '/myplex/account'
request = self.request_handler.make_request(uri=uri,
proto=self.protocol,
request_type='GET',
output_format=output_format)
return request
"""
Return processed and validated list of recently added items.
@ -1650,15 +1666,22 @@ class PmsConnect(object):
return key_list
"""
Check for a server response.
Output: bool
"""
def get_server_response(self):
response = self.get_server_list()
account_data = self.get_account(output_format='xml')
try:
xml_head = account_data.getElementsByTagName('MyPlex')
except:
logger.warn("Unable to parse XML for get_server_response.")
return None
server_response = {}
if not response:
return False
else:
return True
for a in xml_head:
server_response = {'mapping_state': helpers.get_xml_attr(a, 'mappingState'),
'mapping_error': helpers.get_xml_attr(a, 'mappingError'),
'public_address': helpers.get_xml_attr(a, 'publicAddress'),
'public_port': helpers.get_xml_attr(a, 'publicPort')
}
return server_response