Fix onvif client for some cameras

This commit is contained in:
Alex X
2025-10-23 14:42:38 +03:00
parent be80eb1ac9
commit 6db4dda535
2 changed files with 59 additions and 42 deletions
+12
View File
@@ -3,6 +3,7 @@ package onvif
import (
"fmt"
"net"
"net/url"
"regexp"
"strconv"
"strings"
@@ -129,3 +130,14 @@ func GetPosixTZ(current time.Time) string {
return prefix + fmt.Sprintf("%02d:%02d", offset/60, offset%60)
}
func GetPath(urlOrPath, defPath string) string {
if urlOrPath == "" || urlOrPath[0] == '/' {
return defPath
}
u, err := url.Parse(urlOrPath)
if err != nil {
return defPath
}
return GetPath(u.Path, defPath)
}