cameras: map only working HTTP/MJPEG feeds
All checks were successful
build-and-deploy / build (push) Successful in 2m53s

Masscan open-554 hosts almost never have a public picture. The map now
defaults to cameras with an http(s) snapshot_url (~132 directory cams).

Ingest probes unauthenticated still/MJPEG paths first and skips the rest,
so dead RTSP-only hosts never land on the map. Pass working=false to see
unverified port-554 hits.
This commit is contained in:
Sirius DevOps 2026-08-25 22:05:15 -04:00
commit 7ceba736dd
3 changed files with 107 additions and 15 deletions

View file

@ -23,7 +23,7 @@ import structlog
from fastapi import FastAPI, HTTPException, Query
from fastapi.responses import FileResponse, HTMLResponse
from fastapi.staticfiles import StaticFiles
from sqlalchemy import and_, func, select, text
from sqlalchemy import and_, func, or_, select, text
from sqlalchemy.ext.asyncio import AsyncSession
from database import async_session, init_extensions
@ -708,6 +708,12 @@ async def list_cameras(
description="Bounding box 'min_lon,min_lat,max_lon,max_lat'",
),
source: str | None = Query(None, description="Filter by discovery_source"),
working: bool = Query(
True,
description="Only cameras with a verified HTTP/MJPEG snapshot_url "
"(the ones that actually preview). Set false to include "
"unverified masscan port-554 hits.",
),
limit: int = Query(500, ge=1, le=5000),
):
"""Cameras for map display, optionally filtered by geographic bbox."""
@ -715,6 +721,14 @@ async def list_cameras(
async with async_session() as session:
stmt = select(cam_table).order_by(cam_table.c.last_seen.desc())
if working:
stmt = stmt.where(
cam_table.c.snapshot_url.isnot(None),
or_(
cam_table.c.snapshot_url.startswith("http://"),
cam_table.c.snapshot_url.startswith("https://"),
),
)
if bbox:
try:
min_lon, min_lat, max_lon, max_lat = (