mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 16:44:29 +03:00
Use custom body for the export recordings endpoint
This commit is contained in:
parent
a68c7f4ef8
commit
0027e3fd96
0
frigate/api/defs/__init__.py
Normal file
0
frigate/api/defs/__init__.py
Normal file
0
frigate/api/defs/request/__init__.py
Normal file
0
frigate/api/defs/request/__init__.py
Normal file
14
frigate/api/defs/request/export_recordinds_body.py
Normal file
14
frigate/api/defs/request/export_recordinds_body.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
from frigate.record.export import PlaybackFactorEnum
|
||||||
|
|
||||||
|
|
||||||
|
class ExportRecordingsBody(BaseModel):
|
||||||
|
playback: PlaybackFactorEnum = Field(
|
||||||
|
default=PlaybackFactorEnum.realtime, title="Playback factor"
|
||||||
|
)
|
||||||
|
source: str = "recordings"
|
||||||
|
name: str = Field(title="Friendly name", default=None, min_length=1, max_length=256)
|
||||||
|
image_path: Optional[str] = None
|
||||||
@ -4,13 +4,13 @@ import logging
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
from fastapi import APIRouter, Request
|
from fastapi import APIRouter, Request
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
from peewee import DoesNotExist
|
from peewee import DoesNotExist
|
||||||
|
|
||||||
|
from frigate.api.defs.request.export_recordinds_body import ExportRecordingsBody
|
||||||
from frigate.api.defs.tags import Tags
|
from frigate.api.defs.tags import Tags
|
||||||
from frigate.const import EXPORT_DIR
|
from frigate.const import EXPORT_DIR
|
||||||
from frigate.models import Export, Previews, Recordings
|
from frigate.models import Export, Previews, Recordings
|
||||||
@ -37,7 +37,7 @@ def export_recording(
|
|||||||
camera_name: str,
|
camera_name: str,
|
||||||
start_time: float,
|
start_time: float,
|
||||||
end_time: float,
|
end_time: float,
|
||||||
body: dict = None,
|
body: dict = ExportRecordingsBody,
|
||||||
):
|
):
|
||||||
if not camera_name or not request.app.frigate_config.cameras.get(camera_name):
|
if not camera_name or not request.app.frigate_config.cameras.get(camera_name):
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
@ -47,18 +47,10 @@ def export_recording(
|
|||||||
status_code=404,
|
status_code=404,
|
||||||
)
|
)
|
||||||
|
|
||||||
json: dict[str, any] = body or {}
|
playback_factor = body.playback
|
||||||
playback_factor = json.get("playback", "realtime")
|
playback_source = body.source
|
||||||
playback_source = json.get("source", "recordings")
|
friendly_name = body.name
|
||||||
friendly_name: Optional[str] = json.get("name")
|
existing_image = body.image_path
|
||||||
|
|
||||||
if len(friendly_name or "") > 256:
|
|
||||||
return JSONResponse(
|
|
||||||
content=({"success": False, "message": "File name is too long."}),
|
|
||||||
status_code=401,
|
|
||||||
)
|
|
||||||
|
|
||||||
existing_image = json.get("image_path")
|
|
||||||
|
|
||||||
if playback_source == "recordings":
|
if playback_source == "recordings":
|
||||||
recordings_count = (
|
recordings_count = (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user