Upload api.py
Browse files
api.py
CHANGED
|
@@ -189,12 +189,24 @@ def process_video_job(job_id: str):
|
|
| 189 |
folder = ch.get("folder")
|
| 190 |
face_files = []
|
| 191 |
if folder and os.path.isdir(folder):
|
| 192 |
-
# soportar patrones face_
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
ch["face_files"] = face_files
|
| 199 |
# Ajustar num_faces si hay discrepancia
|
| 200 |
if face_files:
|
|
|
|
| 189 |
folder = ch.get("folder")
|
| 190 |
face_files = []
|
| 191 |
if folder and os.path.isdir(folder):
|
| 192 |
+
# soportar patrones face_* y extensiones jpg/png
|
| 193 |
+
patterns = ["face_*.jpg", "face_*.png"]
|
| 194 |
+
files = []
|
| 195 |
+
for pat in patterns:
|
| 196 |
+
files.extend(glob.glob(os.path.join(folder, pat)))
|
| 197 |
+
# si no hay face_*, tomar cualquier jpg/png para no dejar vacío
|
| 198 |
+
if not files:
|
| 199 |
+
files.extend(glob.glob(os.path.join(folder, "*.jpg")))
|
| 200 |
+
files.extend(glob.glob(os.path.join(folder, "*.png")))
|
| 201 |
+
# normalizar nombres de fichero relativos
|
| 202 |
+
face_files = sorted({os.path.basename(p) for p in files})
|
| 203 |
+
# Garantizar que representative.(jpg|png) esté el primero si existe
|
| 204 |
+
for rep_name in ("representative.jpg", "representative.png"):
|
| 205 |
+
rep_path = os.path.join(folder, rep_name)
|
| 206 |
+
if os.path.exists(rep_path):
|
| 207 |
+
if rep_name in face_files:
|
| 208 |
+
face_files.remove(rep_name)
|
| 209 |
+
face_files.insert(0, rep_name)
|
| 210 |
ch["face_files"] = face_files
|
| 211 |
# Ajustar num_faces si hay discrepancia
|
| 212 |
if face_files:
|