mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Improve error checking and handling for recordings export (#7647)
* Improve error checking and handling for recordings export * Cleanup * Remove order by
This commit is contained in:
parent
36434bb26d
commit
db6ee41f3c
@ -1617,7 +1617,31 @@ def vod_event(id):
|
|||||||
methods=["POST"],
|
methods=["POST"],
|
||||||
)
|
)
|
||||||
def export_recording(camera_name: str, start_time, end_time):
|
def export_recording(camera_name: str, start_time, end_time):
|
||||||
playback_factor = request.get_json(silent=True).get("playback", "realtime")
|
if not camera_name or not current_app.frigate_config.cameras.get(camera_name):
|
||||||
|
return make_response(
|
||||||
|
jsonify(
|
||||||
|
{"success": False, "message": f"{camera_name} is not a valid camera."}
|
||||||
|
),
|
||||||
|
404,
|
||||||
|
)
|
||||||
|
|
||||||
|
json: dict[str, any] = request.get_json(silent=True) or {}
|
||||||
|
playback_factor = json.get("playback", "realtime")
|
||||||
|
|
||||||
|
recordings_count = (
|
||||||
|
Recordings.select()
|
||||||
|
.where(
|
||||||
|
Recordings.start_time.between(start_time, end_time)
|
||||||
|
| Recordings.end_time.between(start_time, end_time)
|
||||||
|
| ((start_time > Recordings.start_time) & (end_time < Recordings.end_time))
|
||||||
|
)
|
||||||
|
.where(Recordings.camera == camera_name)
|
||||||
|
.count()
|
||||||
|
)
|
||||||
|
|
||||||
|
if recordings_count <= 0:
|
||||||
|
return "No recordings found for time range", 400
|
||||||
|
|
||||||
exporter = RecordingExporter(
|
exporter = RecordingExporter(
|
||||||
current_app.frigate_config,
|
current_app.frigate_config,
|
||||||
camera_name,
|
camera_name,
|
||||||
|
@ -52,11 +52,17 @@ export default function Export() {
|
|||||||
|
|
||||||
axios
|
axios
|
||||||
.post(`export/${camera}/start/${start}/end/${end}`, { playback })
|
.post(`export/${camera}/start/${start}/end/${end}`, { playback })
|
||||||
.then(() => {
|
.then((response) => {
|
||||||
|
if (response.status == 200) {
|
||||||
setMessage({ text: 'Successfully started export. View the file in the /exports folder.', error: false });
|
setMessage({ text: 'Successfully started export. View the file in the /exports folder.', error: false });
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
if (error.response) {
|
||||||
setMessage({ text: `Failed to start export: ${error.response.data.message}`, error: true });
|
setMessage({ text: `Failed to start export: ${error.response.data.message}`, error: true });
|
||||||
|
} else {
|
||||||
|
setMessage({ text: `Failed to start export: ${error.message}`, error: true });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user