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()