diff --git a/README.md b/README.md index 3609170..2a32bf9 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ You can find docker image in packages section of this github repository or pull | `/operators` | GET | Get operators list | | `/places` | GET | Get places list | | `/snapshot` | GET | Get snapshot by `placeID` and `accessControlID` | -| `/stream` | GET | Get link to stream by `cameraID` | +| `/stream` | GET | Get link to stream by `cameraID`, optionally `placeID` to select the entrance | ## 🤝  Found a bug? Missing a specific feature? diff --git a/handlers/stream.go b/handlers/stream.go index 1ebbff4..4043932 100644 --- a/handlers/stream.go +++ b/handlers/stream.go @@ -23,10 +23,16 @@ func (h *Handler) Stream(r *http.Request) (string, error) { query := r.URL.Query() cameraID := query.Get("cameraID") + // Конвертируем placeID из строки в int64 + placeIDInt, _ := strconv.ParseInt(query.Get("placeID"), 10, 64) + targetRawURL := fmt.Sprintf(API_CAMERA_GET_STREAM, cameraID) targetURL, _ := url.Parse(targetRawURL) - targetURL.RawQuery = r.URL.RawQuery + + // placeID нужен только для User-Agent, наверх его не передаём + query.Del("placeID") + targetURL.RawQuery = query.Encode() request, err := http.NewRequest("GET", targetURL.String(), nil) if err != nil { @@ -42,7 +48,7 @@ func (h *Handler) Stream(r *http.Request) (string, error) { rt := WithHeader(client.Transport) rt.Set("Host", API_HOST) rt.Set("Content-Type", "application/json; charset=UTF-8") - rt.Set("User-Agent", GenerateUserAgent(h.Config.Operator, h.Config.UUID, 0)) + rt.Set("User-Agent", GenerateUserAgent(h.Config.Operator, h.Config.UUID, placeIDInt)) rt.Set("Operator", operator) rt.Set("Authorization", "Bearer "+h.Config.Token) client.Transport = rt