Skip to content

The only downloader you need. 下载器的集大成者。

feat(browser): 添加合并任务输出标题支持并改进FFmpeg错误处理

XiaoYouChR7ed8fe289271
diff --git a/app/services/browser_service.py b/app/services/browser_service.py
index ec6ffb70..1fbfb64b 100644
--- a/app/services/browser_service.py
+++ b/app/services/browser_service.py
@@ -295,6 +295,7 @@ class BrowserService(QObject):
rawPath = rawPayload.get("path")
return {
"url": BrowserVirtualUrl.FFMPEG_MERGE,
+ "outputTitle": self._stringField(rawPayload, "outputTitle"),
"resources": rawPayload.get("resources") or [],
"proxies": getProxies(),
"path": Path(rawPath) if rawPath else Path(cfg.downloadFolder.value),
@@ -385,6 +386,7 @@ class BrowserService(QObject):
if source == BrowserTaskSource.RESOURCE_MERGE:
mergePayload = self._buildMergePayload(payload)
+ mergePayload["outputTitle"] = title
if len(mergePayload["resources"]) != 2:
self._sendResult(
session,
@@ -397,10 +399,10 @@ class BrowserService(QObject):
coreService.runCoroutine(
coreService._parseUrl(mergePayload),
- lambda task, error, session=session, requestId=requestId, title=title: self._onTaskParsed(
+ lambda task, error, session=session, requestId=requestId: self._onTaskParsed(
session,
requestId,
- title,
+ "",
task,
error,
),
diff --git a/features/ffmpeg_pack/task.py b/features/ffmpeg_pack/task.py
index b14c6184..f11acff8 100644
--- a/features/ffmpeg_pack/task.py
+++ b/features/ffmpeg_pack/task.py
@@ -209,6 +209,7 @@ class FFmpegWorker(Worker):
process = None
progressTask = None
+ stderrOutput = ""
try:
self.stage.progress = 0
self.stage.speed = 0
@@ -231,13 +232,17 @@ class FFmpegWorker(Worker):
self.stage.resolvePath,
stdin=asyncio.subprocess.DEVNULL,
stdout=asyncio.subprocess.PIPE,
- stderr=asyncio.subprocess.DEVNULL,
+ stderr=asyncio.subprocess.PIPE,
)
progressTask = asyncio.create_task(self._readProgress(process.stdout, totalDuration))
await process.wait()
await progressTask
+ if process.stderr is not None:
+ stderrOutput = (await process.stderr.read()).decode("utf-8", errors="ignore").strip()
if process.returncode != 0:
+ if stderrOutput:
+ raise RuntimeError(f"ffmpeg 退出码异常: {process.returncode}, {stderrOutput}")
raise RuntimeError(f"ffmpeg 退出码异常: {process.returncode}")
self.stage.setStatus(TaskStatus.COMPLETED)