Skip to content

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

feat(ffmpeg_pack): 合并失败时检测 DRM 加密文件并提示用户

XiaoYouChR8c225ea6ba5a
diff --git a/features/ffmpeg_pack/error_catalog.py b/features/ffmpeg_pack/error_catalog.py
index c8751250..a4142302 100644
--- a/features/ffmpeg_pack/error_catalog.py
+++ b/features/ffmpeg_pack/error_catalog.py
@@ -1,3 +1,4 @@
from PySide6.QtCore import QT_TRANSLATE_NOOP as N
N("TaskErrors", "FFmpeg 合并失败({code}):{detail}")
+N("TaskErrors", "文件不是有效的媒体格式,可能受 DRM 保护或下载不完整:{name}")
diff --git a/features/ffmpeg_pack/task.py b/features/ffmpeg_pack/task.py
index 687d1d11..b45d4b31 100644
--- a/features/ffmpeg_pack/task.py
+++ b/features/ffmpeg_pack/task.py
@@ -13,6 +13,9 @@ from http_pack.task import HttpTaskStep
from .config import ffmpegRuntime
+ISOBMFF_BOX_TYPES = {b'ftyp', b'styp', b'moof', b'moov', b'free', b'skip', b'mdat', b'pdin'}
+
+
def mediaStem(task) -> str:
name = task.name
return name.rsplit(".", 1)[0] if "." in name else name
@@ -85,6 +88,15 @@ class FFmpegStep(TaskStep):
if process.returncode != 0:
stderr = (await process.stderr.read()).decode("utf-8", errors="ignore").strip()
+ for inputPath in (self._videoPath, self._audioPath):
+ if inputPath.exists():
+ with open(inputPath, "rb") as f:
+ boxType = f.read(8)[4:8]
+ if boxType not in ISOBMFF_BOX_TYPES:
+ raise TaskError(
+ "文件不是有效的媒体格式,可能受 DRM 保护或下载不完整:{name}",
+ name=inputPath.name,
+ )
raise TaskError(
"FFmpeg 合并失败({code}):{detail}",
code=process.returncode,