You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
638 B

4 years ago
  1. from netdisco.ssdp import scan
  2. from .upnp import Device
  3. from .util import _getLogger
  4. def discover(timeout=5):
  5. """
  6. Convenience method to discover UPnP devices on the network. Returns a
  7. list of `upnp.Device` instances. Any invalid servers are silently
  8. ignored.
  9. """
  10. devices = {}
  11. for entry in scan(timeout):
  12. if entry.location in devices:
  13. continue
  14. try:
  15. devices[entry.location] = Device(entry.location)
  16. except Exception as exc:
  17. log = _getLogger("ssdp")
  18. log.error('Error \'%s\' for %s', exc, entry.location)
  19. return list(devices.values())