From 7f8c1d0d07d8ac6b3e7eea1747801b6e81f99373 Mon Sep 17 00:00:00 2001 From: Flag Date: Thu, 23 Apr 2026 20:42:56 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20segment=5Flabel=20end-time=20recalcul?= =?UTF-8?q?=C3=A9=20depuis=20video=5Fduration=5Fs=20(exiftool=3D0=20=C3=A0?= =?UTF-8?q?=20lingest)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 3d6eca1..5447fb4 100644 --- a/app/main.py +++ b/app/main.py @@ -193,7 +193,20 @@ def _build_acquisitions(): dur_s = _job_duration_s(j) d["_duration"] = _fmt_dur(dur_s) d["gp_label"] = gp_label.get((j["acquisition_id"], j["auv"], j["gopro_serial"]), "?") - d["video_duration_fmt"] = _fmt_dur(int(j["video_duration_s"] or 0)) if (j["video_duration_s"] or 0) > 0 else "—" + vid_dur_s = float(j["video_duration_s"] or 0) + d["video_duration_fmt"] = _fmt_dur(int(vid_dur_s)) if vid_dur_s > 0 else "—" + # Fix segment_label end-time when exiftool returned duration=0 at ingest + seg_label = j["segment_label"] or "" + if vid_dur_s > 0 and "–" in seg_label: + try: + from datetime import datetime as _dt, timedelta as _td + start_str = seg_label.split("–")[0].strip() + t0 = _dt.strptime(start_str, "%H:%M") + t1 = t0 + _td(seconds=vid_dur_s) + seg_label = f"{start_str}–{t1.strftime('%H:%M')}" + except Exception: + pass + d["segment_label"] = seg_label d["trimmed_total"] = (j["trimmed_head"] or 0) + (j["trimmed_tail"] or 0) thumb_path = DB_PATH.parent / "thumbnails" / f"job_{j['id']}.jpg" d["has_thumbnail"] = thumb_path.is_file()