diff --git a/pyproject.toml b/pyproject.toml index 6056b05..a8041e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zm-py" -version = "0.5.5.dev2" +version = "0.5.5.dev3" description = "A loose python wrapper around the ZoneMinder REST API." authors = ["Rohan Kapoor "] maintainers = ["Nic Boet "] diff --git a/zoneminder/monitor.py b/zoneminder/monitor.py index bc27884..4b14c63 100755 --- a/zoneminder/monitor.py +++ b/zoneminder/monitor.py @@ -132,7 +132,7 @@ def function(self) -> MonitorState: """Get the MonitorState of this Monitor.""" if self.update_monitor(): return MonitorState(self._raw_result["Monitor"]["Function"]) - return "None" + return "Error-MonitorState" @function.setter def function(self, new_function): @@ -187,9 +187,8 @@ def is_available(self) -> bool: # Monitor_Status was only added in ZM 1.32.3 monitor_status = self._raw_result.get("Monitor_Status", None) capture_fps = monitor_status and monitor_status["CaptureFPS"] - monitor_state = monitor_status and monitor_status["Status"] - return monitor_state == "Connected" and capture_fps != "0.00" + return status_response.get("status", False) and capture_fps != "0.00" def get_events(self, time_period, include_archived=False) -> Optional[int]: """Get the number of events that have occurred on this Monitor. diff --git a/zoneminder/zm.py b/zoneminder/zm.py index f0170d9..ed864af 100644 --- a/zoneminder/zm.py +++ b/zoneminder/zm.py @@ -240,18 +240,14 @@ def get_zms_url(self) -> str: def get_url_with_auth(self, url) -> str: """Add the auth credentials to a url (if needed).""" - if not self._username and not self._auth_token: + if not self._username: return url - if self._auth_token: - url += f"&token={quote(self._auth_token)}" - else: - url += f"&user={quote(self._username)}" - if not self._password: - return url - url += f"&pass={quote(self._password)}" - - return url + url += f"&user={quote(self._username)}" + + if not self._password: + return url + return url + f"&pass={quote(self._password)}" @property def is_available(self) -> bool: