Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
10 changes: 8 additions & 2 deletions handlers/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Loading