mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Use Plex API to check remote access down
This commit is contained in:
parent
fd43cf5dd4
commit
013d957e47
4 changed files with 60 additions and 57 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue