Get camera details

This commit is contained in:
2026-03-01 04:33:37 +01:00
parent 7e58b16c51
commit 4219afb93c
4 changed files with 827 additions and 18 deletions

32
main.py
View File

@@ -1,24 +1,22 @@
import cv2
import os
STREAM_URL = "rtsps://192.168.1.1:7441/1bIx3jYaXNxSPXlF?enableSrtp"
OUTPUT = "data/frame.jpg"
import httpx
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.environ["API_KEY"]
HOST = os.environ["HOST"]
BASE = f"https://{HOST}/proxy/protect/integration/v1"
HEADERS = {"Accept": "application/json", "X-API-Key": API_KEY}
def main():
cap = cv2.VideoCapture(STREAM_URL, cv2.CAP_FFMPEG)
if not cap.isOpened():
print("Failed to open stream")
return
ret, frame = cap.read()
cap.release()
if not ret:
print("Failed to read frame")
return
cv2.imwrite(OUTPUT, frame)
print(f"Saved {OUTPUT}")
with httpx.Client(headers=HEADERS, verify=False) as client:
cameras = client.get(f"{BASE}/cameras").raise_for_status().json()
camera = next(c for c in cameras if "G6 Pro 360" in c["name"])
print(f"Camera: {camera['name']} ({camera['id']})")
print(f"Has speaker: {camera['featureFlags']['hasSpeaker']}")
if __name__ == "__main__":