From 8b5eaeae26b26cebe12405c5ebd31fdaaa75fa60 Mon Sep 17 00:00:00 2001 From: MPippin Date: Sun, 15 May 2022 04:38:03 -0500 Subject: [PATCH] bug fix Uncaught Exception in discover() #17 --- upnpy/ssdp/SSDPDevice.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/upnpy/ssdp/SSDPDevice.py b/upnpy/ssdp/SSDPDevice.py index 0760246..d15bab2 100644 --- a/upnpy/ssdp/SSDPDevice.py +++ b/upnpy/ssdp/SSDPDevice.py @@ -162,13 +162,15 @@ def _get_services_request(self): root = minidom.parseString(self.description) base_url = self.base_url - for service in root.getElementsByTagName('service'): service_string = service.getElementsByTagName('serviceType')[0].firstChild.nodeValue service_id = service.getElementsByTagName('serviceId')[0].firstChild.nodeValue scpd_url = service.getElementsByTagName('SCPDURL')[0].firstChild.nodeValue - control_url = service.getElementsByTagName('controlURL')[0].firstChild.nodeValue - event_sub_url = service.getElementsByTagName('eventSubURL')[0].firstChild.nodeValue + control_url = None + event_sub_url = None + if service.getElementsByTagName('controlURL')[0].firstChild: + control_url = service.getElementsByTagName('controlURL')[0].firstChild.nodeValue + event_sub_url = service.getElementsByTagName('eventSubURL')[0].firstChild.nodeValue parsed_service_id = utils.parse_service_id(service_id)