From 073bfff5a5b02ed360de7d17878c48ae3403c769 Mon Sep 17 00:00:00 2001 From: Thales Pereira <31625914+thcp@users.noreply.github.com> Date: Thu, 18 Jun 2026 09:07:17 +0100 Subject: [PATCH] feat: add MP4 and M4A upload support, raise limit to 400 MB Closes #209 --- app/api/jobs.py | 10 +++++----- static/index.html | 2 +- static/js/main.js | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/api/jobs.py b/app/api/jobs.py index 7fc8df8b..17dc365c 100644 --- a/app/api/jobs.py +++ b/app/api/jobs.py @@ -33,8 +33,8 @@ router = APIRouter(tags=["jobs"]) logger = logging.getLogger("stemdeck.api") -_ALLOWED_EXTS = frozenset((".mp3", ".wav", ".flac")) -_MAX_UPLOAD_BYTES = 100 * 1024 * 1024 # 100 MB +_ALLOWED_EXTS = frozenset((".mp3", ".wav", ".flac", ".mp4", ".m4a")) +_MAX_UPLOAD_BYTES = 400 * 1024 * 1024 # 400 MB _WS_RE = re.compile(r"\s+") @@ -161,7 +161,7 @@ async def _create_local_job(request: Request) -> dict[str, str]: if cl_header: try: if int(cl_header) > _MAX_UPLOAD_BYTES + 4096: - raise HTTPException(status_code=422, detail="File exceeds 100 MB limit") + raise HTTPException(status_code=422, detail="File exceeds 400 MB limit") except ValueError: pass @@ -177,7 +177,7 @@ async def _create_local_job(request: Request) -> dict[str, str]: if ext not in _ALLOWED_EXTS: raise HTTPException( status_code=422, - detail=f"Unsupported file type '{ext}': only .mp3, .wav, and .flac are accepted", + detail=f"Unsupported file type '{ext}': accepted formats are .mp3, .wav, .flac, .mp4, and .m4a", ) # Validate stems list from form field @@ -196,7 +196,7 @@ async def _create_local_job(request: Request) -> dict[str, str]: if file_size == 0: raise HTTPException(status_code=422, detail="Uploaded file is empty") if file_size > _MAX_UPLOAD_BYTES: - raise HTTPException(status_code=422, detail="File exceeds 100 MB limit") + raise HTTPException(status_code=422, detail="File exceeds 400 MB limit") job_id = uuid.uuid4().hex[:12] job_dir = JOBS_DIR / job_id diff --git a/static/index.html b/static/index.html index f8bb80fb..4c237898 100644 --- a/static/index.html +++ b/static/index.html @@ -57,7 +57,7 @@ - + diff --git a/static/js/main.js b/static/js/main.js index 0d71b6d1..2f1821c1 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -271,17 +271,18 @@ function wireFileDrop() { return n < 1024 * 1024 ? `${(n / 1024).toFixed(0)} KB` : `${(n / 1024 / 1024).toFixed(1)} MB`; } - const MAX_UPLOAD_BYTES = 100 * 1024 * 1024; // must match server _MAX_UPLOAD_BYTES + const MAX_UPLOAD_BYTES = 400 * 1024 * 1024; // must match server _MAX_UPLOAD_BYTES function applyFile(file) { if (!file) return; const lower = file.name.toLowerCase(); - if (!lower.endsWith(".mp3") && !lower.endsWith(".wav") && !lower.endsWith(".flac")) { - showError("Only MP3, WAV, and FLAC files are supported."); + if (!lower.endsWith(".mp3") && !lower.endsWith(".wav") && !lower.endsWith(".flac") && + !lower.endsWith(".mp4") && !lower.endsWith(".m4a")) { + showError("Only MP3, WAV, FLAC, MP4, and M4A files are supported."); return; } if (file.size > MAX_UPLOAD_BYTES) { - showError(`File is too large (${formatBytes(file.size)}). Maximum is 100 MB.`); + showError(`File is too large (${formatBytes(file.size)}). Maximum is 400 MB.`); return; } if (fileName) fileName.textContent = file.name;