VeuReu commited on
Commit
ead00e5
·
verified ·
1 Parent(s): a03de49

Upload api.py

Browse files
Files changed (1) hide show
  1. api.py +18 -6
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_*.jpg y representative.jpg
193
- face_files = sorted([os.path.basename(p) for p in glob.glob(os.path.join(folder, "face_*.jpg"))])
194
- # Garantizar que representative.jpg está accesible aunque no haya faces
195
- rep_path = os.path.join(folder, "representative.jpg")
196
- if os.path.exists(rep_path) and "representative.jpg" not in face_files:
197
- face_files.insert(0, "representative.jpg")
 
 
 
 
 
 
 
 
 
 
 
 
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: