fix: UUID→fichier via API photobooth (created_at/processed), photo_id dans print_queue
🚀 Deploy — JH Photomaton / 🔍 Vérification (push) Has been cancelled
🚀 Deploy — JH Photomaton / 🍓 Deploy sur le Pi (push) Has been cancelled

This commit is contained in:
2026-07-17 16:44:33 +02:00
parent 4592f20be3
commit 742186ec8e
4 changed files with 86 additions and 94 deletions
+12 -25
View File
@@ -2,7 +2,7 @@
import asyncio
import logging
from datetime import datetime
from datetime import datetime, timezone
from pathlib import Path
import httpx
@@ -50,31 +50,18 @@ async def api_gallery_photos(
if ev:
started_at = ev["started_at"] or 0.0
ended_at = ev["ended_at"] or datetime.now().timestamp()
# Construire un index mtime : cherche dans media_dir et ses sous-dossiers connus
mtime_index: dict[str, float] = {}
base = Path(cfg.photobooth.media_dir)
checked: set = set()
for candidate in [
base,
base / "processed_full",
Path("/home/pi/photobooth-data/media/processed_full"),
Path("/home/pi/photobooth-data/media"),
]:
if not candidate.exists() or candidate in checked:
continue
checked.add(candidate)
for f in candidate.iterdir():
if f.is_file() and f.suffix.lower() in (".jpg", ".jpeg", ".png"):
mt = f.stat().st_mtime
mtime_index[f.name] = mt
mtime_index[f.stem] = mt
def _in_event(p: dict) -> bool:
pid = _get_id(p)
stem = pid.rsplit(".", 1)[0] if "." in pid else pid
mt = mtime_index.get(pid) or mtime_index.get(stem) or 0.0
return mt > 0 and started_at <= mt <= ended_at
photos = [p for p in photos if _in_event(p)]
def _photo_ts(p: dict) -> float:
"""Timestamp UTC de la photo depuis le champ created_at de photobooth-app."""
created_str = p.get("created_at", "")
try:
return datetime.fromisoformat(created_str).replace(
tzinfo=timezone.utc
).timestamp()
except (ValueError, TypeError):
return 0.0
photos = [p for p in photos if started_at <= _photo_ts(p) <= ended_at]
total = len(photos)
start = (page - 1) * limit