Skip to content

Commit bda666f

Browse files
committed
include webm playback, install ffmpeg in Dockerfile, exception catch in ytdlp subprocess
1 parent 9daf365 commit bda666f

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ RUN pnpm exec vite build
1313

1414
FROM ghcr.io/astral-sh/uv:0.8-python3.11-bookworm
1515

16+
RUN apt-get update && \
17+
apt-get install -y ffmpeg && \
18+
apt-get clean
19+
1620
COPY apiserver/ /app/apiserver
1721
COPY apiserver/docker.config.yaml /app/apiserver/config.yaml
1822

apiserver/app.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,20 @@ async def download_via_ytdlp(url: str, args: str):
452452
f"Executing command: {' '.join(shlex.quote(part) for part in full_command)}"
453453
)
454454

455-
process = await asyncio.create_subprocess_exec(
456-
*full_command,
457-
stdout=subprocess.PIPE,
458-
stderr=subprocess.PIPE,
459-
env={**os.environ, "PYTHONUNBUFFERED": "1"},
460-
)
461-
462455
full_command_str = " ".join(full_command)
463456

457+
try:
458+
process = await asyncio.create_subprocess_exec(
459+
*full_command,
460+
stdout=subprocess.PIPE,
461+
stderr=subprocess.PIPE,
462+
env={**os.environ, "PYTHONUNBUFFERED": "1"},
463+
)
464+
465+
except Exception as e:
466+
logging.exception(f"Failed to start process: {full_command_str}")
467+
raise HTTPException(status_code=500, detail=f"Failed to start process: {e}")
468+
464469
return StreamingResponse(
465470
_stream_subprocess_output(process, url, full_command_str),
466471
media_type="text/event-stream",
@@ -573,7 +578,7 @@ def delete_downloaded_file(filename: str):
573578
try:
574579
os.remove(full_path)
575580

576-
media_exts = [".mp3", ".mp4", ".m4a", ".mkv"]
581+
media_exts = [".mp3", ".mp4", ".m4a", ".mkv", ".webm"]
577582
exts = [".info.json", ".description", ".webp", ".png", ".jpeg", ".jpg"]
578583

579584
other_media_files = any(

apiserver/app_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# app_test.py
22
import pytest
3-
from pathlib import Path
43
import os
54
import shutil
65
from fastapi.testclient import TestClient

0 commit comments

Comments
 (0)