Update app.py
Browse files
app.py
CHANGED
|
@@ -449,47 +449,59 @@ def poster(vid: str):
|
|
| 449 |
return FileResponse(str(p), media_type="image/jpeg")
|
| 450 |
raise HTTPException(404, "Poster introuvable")
|
| 451 |
|
|
|
|
| 452 |
@app.get("/window/{vid}", tags=["io"])
|
| 453 |
def window(vid: str, center: int = 0, count: int = 21):
|
| 454 |
v = DATA_DIR / vid
|
| 455 |
if not v.exists():
|
| 456 |
raise HTTPException(404, "Vidéo introuvable")
|
|
|
|
| 457 |
m = _meta(v)
|
| 458 |
if not m:
|
| 459 |
raise HTTPException(500, "Métadonnées indisponibles")
|
| 460 |
-
|
|
|
|
| 461 |
count = max(3, int(count))
|
| 462 |
-
center = max(0, min(int(center), max(0, frames-1)))
|
|
|
|
| 463 |
if frames <= 0:
|
| 464 |
print(f"[WINDOW] frames=0 for {vid}", file=sys.stdout)
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
|
| 488 |
-
@app.post("/warmup/stop", tags=["warmup"])
|
| 489 |
-
def warmup_stop_api():
|
| 490 |
-
warmup_stop.set()
|
| 491 |
-
return {"stopping": True}
|
| 492 |
-
# <<<< HUGINFACE PATCH: WARMUP ROUTES END >>>>
|
| 493 |
# ----- Masques -----
|
| 494 |
|
| 495 |
@app.post("/mask", tags=["mask"])
|
|
|
|
| 449 |
return FileResponse(str(p), media_type="image/jpeg")
|
| 450 |
raise HTTPException(404, "Poster introuvable")
|
| 451 |
|
| 452 |
+
# >>> A1_BEGIN window_fix
|
| 453 |
@app.get("/window/{vid}", tags=["io"])
|
| 454 |
def window(vid: str, center: int = 0, count: int = 21):
|
| 455 |
v = DATA_DIR / vid
|
| 456 |
if not v.exists():
|
| 457 |
raise HTTPException(404, "Vidéo introuvable")
|
| 458 |
+
|
| 459 |
m = _meta(v)
|
| 460 |
if not m:
|
| 461 |
raise HTTPException(500, "Métadonnées indisponibles")
|
| 462 |
+
|
| 463 |
+
frames = int(m.get("frames") or 0)
|
| 464 |
count = max(3, int(count))
|
| 465 |
+
center = max(0, min(int(center), max(0, frames - 1)))
|
| 466 |
+
|
| 467 |
if frames <= 0:
|
| 468 |
print(f"[WINDOW] frames=0 for {vid}", file=sys.stdout)
|
| 469 |
+
return {
|
| 470 |
+
"vid": vid,
|
| 471 |
+
"start": 0,
|
| 472 |
+
"count": 0,
|
| 473 |
+
"selected": 0,
|
| 474 |
+
"items": [],
|
| 475 |
+
"frames": 0,
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
if frames <= count:
|
| 479 |
+
start = 0
|
| 480 |
+
sel = center
|
| 481 |
+
n = frames
|
| 482 |
+
else:
|
| 483 |
+
start = max(0, min(center - (count // 2), frames - count))
|
| 484 |
+
n = count
|
| 485 |
+
sel = center - start
|
| 486 |
+
|
| 487 |
+
items = []
|
| 488 |
+
bust = int(time.time() * 1000)
|
| 489 |
+
for i in range(n):
|
| 490 |
+
idx = start + i
|
| 491 |
+
url = f"/thumbs/f_{v.stem}_{idx}.jpg?b={bust}"
|
| 492 |
+
items.append({"i": i, "idx": idx, "url": url})
|
| 493 |
+
|
| 494 |
+
print(f"[WINDOW] {vid} start={start} n={n} sel={sel} frames={frames}", file=sys.stdout)
|
| 495 |
+
return {
|
| 496 |
+
"vid": vid,
|
| 497 |
+
"start": start,
|
| 498 |
+
"count": n,
|
| 499 |
+
"selected": sel,
|
| 500 |
+
"items": items,
|
| 501 |
+
"frames": frames,
|
| 502 |
+
}
|
| 503 |
+
# >>> A1_END window_fix
|
| 504 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 505 |
# ----- Masques -----
|
| 506 |
|
| 507 |
@app.post("/mask", tags=["mask"])
|