Add camera presets snapshots and continuous recording playback

This commit is contained in:
Codex
2026-10-04 08:33:00 +08:00
parent 14f722fa69
commit 68be32e269
15 changed files with 513 additions and 43 deletions
+7 -2
View File
@@ -4,6 +4,7 @@ import datetime as dt
import hashlib
import secrets
import urllib.request
import urllib.error
import urllib.parse
import xml.etree.ElementTree as ET
from xml.sax.saxutils import escape
@@ -39,8 +40,12 @@ def request(host, port, endpoint, namespace, operation, content, username, passw
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), NoRedirect(), urllib.request.HTTPDigestAuthHandler(passwords))
req = urllib.request.Request(target, data=envelope.encode(), headers={
'Content-Type': 'application/soap+xml; charset=utf-8; action="' + namespace + '/' + operation + '"'})
with opener.open(req, timeout=5) as response:
root = ET.fromstring(response.read(1024 * 1024))
try:
with opener.open(req, timeout=5) as response:
root = ET.fromstring(response.read(1024 * 1024))
except urllib.error.HTTPError as exc:
exc.close()
raise
if root.find('.//{http://www.w3.org/2003/05/soap-envelope}Fault') is not None:
raise ValueError('ONVIF returned a fault; check device credentials and permissions')
return root