'Query plex for all servers online. Returns the ones you own in a selectize format'

def discover(self):

    servers = self.get_plextv_resources(include_https=True, output_format='xml')
    clean_servers = []
    try:
        xml_head = servers.getElementsByTagName('MediaContainer')
    except Exception as e:
        logger.warn((u'PlexPy    PlexTV    ::    Failed    to    get    servers    from    plex:    %s.' % e))
        return []
    for a in xml_head:
        if a.getAttribute('size'):
            if (a.getAttribute('size') == '0'):
                return []
        if a.getElementsByTagName('Device'):
            devices = a.getElementsByTagName('Device')
            for d in devices:
                if ((helpers.get_xml_attr(d, 'presence') == '1') and (helpers.get_xml_attr(d, 'owned') == '1') and (helpers.get_xml_attr(d, 'provides') == 'server')):
                    connections = d.getElementsByTagName('Connection')
                    for c in connections:
                        if ((helpers.get_xml_attr(d, 'publicAddressMatches') == '0') and (helpers.get_xml_attr(c, 'local') == '1')):
                            continue
                        if ((helpers.get_xml_attr(d, 'publicAddressMatches') == '1') and (helpers.get_xml_attr(c, 'local') == '0')):
                            continue
                        server = {'httpsRequired': helpers.get_xml_attr(d, 'httpsRequired'), 'clientIdentifier': helpers.get_xml_attr(d, 'clientIdentifier'), 'label': helpers.get_xml_attr(d, 'name'), 'ip': helpers.get_xml_attr(c, 'address'), 'port': helpers.get_xml_attr(c, 'port'), 'local': helpers.get_xml_attr(c, 'local'), 'value': helpers.get_xml_attr(c, 'address')}
                        clean_servers.append(server)
    return clean_servers
