update
This commit is contained in:
+21
-4
@@ -8,7 +8,7 @@ from pathlib import Path
|
||||
|
||||
from fastapi import Body, FastAPI, File, HTTPException, Query, UploadFile
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import StreamingResponse
|
||||
from fastapi.responses import FileResponse, StreamingResponse
|
||||
|
||||
from . import db, jobs, media, mkv, schemas
|
||||
from .settings import APP_NAME, JOBS_DIR, PROJECTS_DIR, UPLOADS_DIR, BLACKDETECT_WINDOW
|
||||
@@ -340,7 +340,8 @@ def split_video(
|
||||
log_cb=lambda message: job_manager.log(job_id, message),
|
||||
custom_segments=custom_segments,
|
||||
)
|
||||
return {"outputs": outputs, "output_dir": str(output_dir)}
|
||||
db.mark_video_exported(video_id)
|
||||
return {"outputs": [Path(o).name for o in outputs], "output_dir": str(output_dir)}
|
||||
|
||||
job_manager.run_in_thread(job_id, run_job)
|
||||
return job_manager.get_job(job_id)
|
||||
@@ -386,7 +387,7 @@ def split_all_videos(payload: schemas.SplitAllRequest | None = Body(default=None
|
||||
project_dir = _project_dir(project["id"])
|
||||
all_outputs: list[str] = []
|
||||
total_videos = len(ready)
|
||||
for video_index, (video, markers) in enumerate(ready, start=1):
|
||||
for video_index, (video, markers, custom_segments) in enumerate(ready, start=1):
|
||||
label = f"{video_index}/{total_videos} {Path(video['filename']).stem}"
|
||||
output_dir = project_dir / "outputs" / video["id"]
|
||||
temp_dir = JOBS_DIR / job_id / video["id"]
|
||||
@@ -412,8 +413,10 @@ def split_all_videos(payload: schemas.SplitAllRequest | None = Body(default=None
|
||||
span=1.0 / float(total_videos),
|
||||
),
|
||||
log_cb=lambda message: job_manager.log(job_id, message),
|
||||
custom_segments=custom_segments,
|
||||
)
|
||||
all_outputs.extend(outputs)
|
||||
db.mark_video_exported(video["id"])
|
||||
all_outputs.extend([Path(o).name for o in outputs])
|
||||
|
||||
return {"outputs": all_outputs, "skipped": skipped}
|
||||
|
||||
@@ -456,3 +459,17 @@ def get_frame(
|
||||
media_type="image/jpeg",
|
||||
headers={"Cache-Control": "public, max-age=86400"},
|
||||
)
|
||||
|
||||
|
||||
@app.get("/api/videos/{video_id}/outputs/{filename}")
|
||||
def download_output(video_id: str, filename: str):
|
||||
project = _require_project()
|
||||
project_dir = _project_dir(project["id"])
|
||||
file_path = project_dir / "outputs" / video_id / filename
|
||||
if not file_path.exists():
|
||||
raise HTTPException(status_code=404, detail="Output file not found")
|
||||
return FileResponse(
|
||||
path=file_path,
|
||||
filename=filename,
|
||||
media_type="video/x-matroska",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user