updates UI
This commit is contained in:
@@ -2452,19 +2452,28 @@ def _get_grouped_wireframes(wireframe_dir: str) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _update_static_videos() -> dict:
|
||||
output_dir = _load_output_dir()
|
||||
data_dir = os.path.join(output_dir, "_data")
|
||||
os.makedirs(data_dir, exist_ok=True)
|
||||
wireframe_dir = _load_wireframe_dir()
|
||||
data = _get_grouped_wireframes(wireframe_dir)
|
||||
_write_json(os.path.join(data_dir, "videos.json"), data)
|
||||
return data
|
||||
|
||||
|
||||
@app.get("/videos")
|
||||
def list_videos():
|
||||
def list_videos(refresh: bool = False):
|
||||
"""Return available wireframe template videos and grouped wireframe assets."""
|
||||
output_dir = _load_output_dir()
|
||||
static_file = os.path.join(output_dir, "_data", "videos.json")
|
||||
if os.path.exists(static_file):
|
||||
if not refresh and os.path.exists(static_file):
|
||||
try:
|
||||
with open(static_file, "r") as f:
|
||||
return json.load(f)
|
||||
except Exception as static_err:
|
||||
print(f"[static-get] Failed to load videos.json: {static_err}")
|
||||
wireframe_dir = _load_wireframe_dir()
|
||||
return _get_grouped_wireframes(wireframe_dir)
|
||||
return _update_static_videos()
|
||||
|
||||
|
||||
@app.get("/wireframe/frame/{video_name}")
|
||||
@@ -2557,6 +2566,11 @@ def trim_wireframe(req: TrimRequest):
|
||||
if r.returncode != 0:
|
||||
raise HTTPException(500, f"ffmpeg error: {r.stderr.decode(errors='replace')[:500]}")
|
||||
|
||||
try:
|
||||
_update_static_videos()
|
||||
except Exception as update_err:
|
||||
print(f"[trim] Failed to update static videos: {update_err}")
|
||||
|
||||
return {'output_name': out_name, 'start': req.start, 'end': req.end}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user