Skip to content

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

feat(i18n): 错误消息改为中文源文本

XiaoYouChR461c2584d641
diff --git a/app/models/task.py b/app/models/task.py
index 4f3ef5e9..04df616c 100644
--- a/app/models/task.py
+++ b/app/models/task.py
@@ -411,7 +411,7 @@ class Task:
except Exception as e:
if currentStep is not None:
currentStep.setError(StepError(
- "Unexpected error: {detail}",
+ "发生了意外错误:{detail}",
{"detail": str(e) or type(e).__name__}
))
logger.opt(exception=e).error("{} failed", self.name)
diff --git a/app/view/error_catalog.py b/app/view/error_catalog.py
index dc58fe1b..aecb0780 100644
--- a/app/view/error_catalog.py
+++ b/app/view/error_catalog.py
@@ -1,7 +1,7 @@
from PySide6.QtCore import QT_TRANSLATE_NOOP as N
-N("TaskErrors", "Binary not found: {name}")
-N("TaskErrors", "Server returned error ({status})")
-N("TaskErrors", "Cannot establish FTP connection")
-N("TaskErrors", "Process exited with error ({code}): {detail}")
-N("TaskErrors", "Unexpected error: {detail}")
+N("TaskErrors", "{name} 未安装,请在设置中安装")
+N("TaskErrors", "服务器返回了错误({status})")
+N("TaskErrors", "无法建立 FTP 连接")
+N("TaskErrors", "进程异常退出({code}):{detail}")
+N("TaskErrors", "发生了意外错误:{detail}")
diff --git a/features/bittorrent_pack/error_catalog.py b/features/bittorrent_pack/error_catalog.py
index 2028c921..0eb7acfa 100644
--- a/features/bittorrent_pack/error_catalog.py
+++ b/features/bittorrent_pack/error_catalog.py
@@ -1,6 +1,6 @@
from PySide6.QtCore import QT_TRANSLATE_NOOP as N
-N("TaskErrors", "Torrent is already downloading")
-N("TaskErrors", "No files selected for download")
-N("TaskErrors", "BitTorrent error: {detail}")
-N("TaskErrors", "BitTorrent session failed: {detail}")
+N("TaskErrors", "该种子已在下载中")
+N("TaskErrors", "至少需要选择一个文件")
+N("TaskErrors", "BitTorrent 错误:{detail}")
+N("TaskErrors", "BitTorrent 会话启动失败:{detail}")
diff --git a/features/bittorrent_pack/task.py b/features/bittorrent_pack/task.py
index 07cd7ff2..1df19c86 100644
--- a/features/bittorrent_pack/task.py
+++ b/features/bittorrent_pack/task.py
@@ -169,7 +169,7 @@ class BTTask(Task):
eh = existing.info_hashes()
if (hashes.has_v1() and eh.has_v1() and hashes.v1 == eh.v1) or \
(hashes.has_v2() and eh.has_v2() and hashes.v2 == eh.v2):
- raise TaskError("Torrent is already downloading")
+ raise TaskError("该种子已在下载中")
handle = session.add_torrent(params)
@@ -189,7 +189,7 @@ class BTTaskStep(TaskStep):
task: BTTask = self.task
if task.countSelected <= 0:
- raise TaskError("No files selected for download")
+ raise TaskError("至少需要选择一个文件")
target = Path(task.outputPath)
if not target.exists():
@@ -206,7 +206,7 @@ class BTTaskStep(TaskStep):
btSession.open()
session = btSession.session()
except Exception as e:
- raise TaskError("BitTorrent session failed: {detail}", detail=str(e)) from e
+ raise TaskError("BitTorrent 会话启动失败:{detail}", detail=str(e)) from e
handle = task._addTorrent(session)
handle.resume()
@@ -331,7 +331,7 @@ class BTTaskStep(TaskStep):
if isinstance(alert, ERROR_ALERTS):
if not self._downloadDone.done():
self._downloadDone.set_exception(
- TaskError("BitTorrent error: {detail}", detail=alert.message())
+ TaskError("BitTorrent 错误:{detail}", detail=alert.message())
)
async def _saveResume(self):
diff --git a/features/disk_pack/error_catalog.py b/features/disk_pack/error_catalog.py
index 62b7dfe1..aae10ed8 100644
--- a/features/disk_pack/error_catalog.py
+++ b/features/disk_pack/error_catalog.py
@@ -1,9 +1,9 @@
from PySide6.QtCore import QT_TRANSLATE_NOOP as N
-N("TaskErrors", "Archive contains unsafe path: {path}")
-N("TaskErrors", "Archive not found: {path}")
-N("TaskErrors", "Unsupported archive format: {name}")
-N("TaskErrors", "Executable not found after extraction: {name}")
-N("TaskErrors", "Could not read SHA256 from checksum file: {path}")
-N("TaskErrors", "SHA256 mismatch: expected {expected}, got {actual}")
-N("TaskErrors", "Downloaded binary not found: {path}")
+N("TaskErrors", "压缩包包含不安全路径:{path}")
+N("TaskErrors", "压缩包未找到:{path}")
+N("TaskErrors", "不支持的压缩格式:{name}")
+N("TaskErrors", "解压后未找到可执行文件:{name}")
+N("TaskErrors", "无法读取校验文件:{path}")
+N("TaskErrors", "SHA256 校验失败:期望 {expected},实际 {actual}")
+N("TaskErrors", "下载的文件未找到:{path}")
diff --git a/features/disk_pack/task.py b/features/disk_pack/task.py
index cc8ef826..14fbbc77 100644
--- a/features/disk_pack/task.py
+++ b/features/disk_pack/task.py
@@ -63,7 +63,7 @@ class ExtractStep(TaskStep):
for info in files:
memberPath = (outputFolder / info.filename).resolve()
if safeRoot not in {memberPath, *memberPath.parents}:
- raise TaskError("Archive contains unsafe path: {path}", path=info.filename)
+ raise TaskError("压缩包包含不安全路径:{path}", path=info.filename)
memberPath.parent.mkdir(parents=True, exist_ok=True)
with zf.open(info, "r") as source, open(memberPath, "wb") as target:
while chunk := source.read(CHUNK_SIZE):
@@ -90,7 +90,7 @@ class ExtractStep(TaskStep):
for member in files:
memberPath = (outputFolder / member.name).resolve()
if safeRoot not in {memberPath, *memberPath.parents}:
- raise TaskError("Archive contains unsafe path: {path}", path=member.name)
+ raise TaskError("压缩包包含不安全路径:{path}", path=member.name)
memberPath.parent.mkdir(parents=True, exist_ok=True)
source = tf.extractfile(member)
if source is None:
@@ -111,7 +111,7 @@ class ExtractStep(TaskStep):
async def run(self) -> None:
archive = Path(self.archivePath)
if not archive.is_file():
- raise TaskError("Archive not found: {path}", path=str(archive))
+ raise TaskError("压缩包未找到:{path}", path=str(archive))
outputFolder = Path(self.outputFolder)
self.progress = 0
@@ -125,7 +125,7 @@ class ExtractStep(TaskStep):
elif lowered.endswith(".zip"):
await self._extractZip(archive, outputFolder)
else:
- raise TaskError("Unsupported archive format: {name}", name=archive.name)
+ raise TaskError("不支持的压缩格式:{name}", name=archive.name)
self.setStatus(TaskStatus.COMPLETED)
@@ -172,7 +172,7 @@ class InstallStep(TaskStep):
if executable is None:
executable = next((c for c in installFolder.rglob(name) if c.is_file()), None)
if executable is None:
- raise TaskError("Executable not found after extraction: {name}", name=name)
+ raise TaskError("解压后未找到可执行文件:{name}", name=name)
if sys.platform != "win32":
executable.chmod(executable.stat().st_mode | 0o755)
# removeQuarantine(executable) # disabled — see removeQuarantine note
@@ -197,10 +197,10 @@ class ChecksumStep(TaskStep):
text = Path(self.sha256File).read_text(encoding="utf-8", errors="ignore").strip()
expected = text.split()[0].lower() if text else ""
if not expected:
- raise TaskError("Could not read SHA256 from checksum file: {path}", path=self.sha256File)
+ raise TaskError("无法读取校验文件:{path}", path=self.sha256File)
actual = await asyncio.to_thread(self._sha256, Path(self.targetFile))
if expected != actual:
- raise TaskError("SHA256 mismatch: expected {expected}, got {actual}", expected=expected, actual=actual)
+ raise TaskError("SHA256 校验失败:期望 {expected},实际 {actual}", expected=expected, actual=actual)
deletePath(Path(self.sha256File))
self.setStatus(TaskStatus.COMPLETED)
@@ -221,7 +221,7 @@ class BinaryInstallStep(TaskStep):
async def run(self) -> None:
path = Path(self.binaryPath)
if not path.is_file():
- raise TaskError("Downloaded binary not found: {path}", path=str(path))
+ raise TaskError("下载的文件未找到:{path}", path=str(path))
if sys.platform != "win32":
path.chmod(path.stat().st_mode | 0o755)
# removeQuarantine(path) # disabled — see removeQuarantine note
diff --git a/features/ed2k_pack/error_catalog.py b/features/ed2k_pack/error_catalog.py
index a0a26ffa..f8d5f359 100644
--- a/features/ed2k_pack/error_catalog.py
+++ b/features/ed2k_pack/error_catalog.py
@@ -1,3 +1,3 @@
from PySide6.QtCore import QT_TRANSLATE_NOOP as N
-N("TaskErrors", "ED2k error: {detail}")
+N("TaskErrors", "ED2k 错误:{detail}")
diff --git a/features/ed2k_pack/task.py b/features/ed2k_pack/task.py
index 44fb6a32..93b8a0a7 100644
--- a/features/ed2k_pack/task.py
+++ b/features/ed2k_pack/task.py
@@ -51,7 +51,7 @@ class ED2kTaskStep(TaskStep):
transfer = await client.addLink(task.url, task.outputFolder)
except Error as e:
if e.code != ErrorCode.TRANSFER_EXISTS:
- raise TaskError("ED2k error: {detail}", detail=str(e)) from e
+ raise TaskError("ED2k 错误:{detail}", detail=str(e)) from e
_, _, linkHash = parseEd2kLink(task.url)
await client.remove(linkHash, deleteFile=False)
transfer = await client.addLink(task.url, task.outputFolder)
@@ -91,7 +91,7 @@ class ED2kInstallStep(TaskStep):
async def run(self) -> None:
path = Path(self.binaryPath)
if not path.is_file():
- raise TaskError("Binary not found: {name}", name="goed2kd")
+ raise TaskError("{name} 未安装,请在设置中安装", name="goed2kd")
if sys.platform != "win32":
path.chmod(path.stat().st_mode | 0o755)
self.setStatus(TaskStatus.COMPLETED)
diff --git a/features/ffmpeg_pack/error_catalog.py b/features/ffmpeg_pack/error_catalog.py
index 5648bbab..c8751250 100644
--- a/features/ffmpeg_pack/error_catalog.py
+++ b/features/ffmpeg_pack/error_catalog.py
@@ -1,3 +1,3 @@
from PySide6.QtCore import QT_TRANSLATE_NOOP as N
-N("TaskErrors", "FFmpeg merge failed ({code}): {detail}")
+N("TaskErrors", "FFmpeg 合并失败({code}):{detail}")
diff --git a/features/ffmpeg_pack/task.py b/features/ffmpeg_pack/task.py
index 26dda953..877a5260 100644
--- a/features/ffmpeg_pack/task.py
+++ b/features/ffmpeg_pack/task.py
@@ -56,7 +56,7 @@ class FFmpegStep(TaskStep):
ffmpegPath = ffmpegRuntime.path()
ffprobePath = ffmpegRuntime.ffprobePath()
if not ffmpegPath or not ffprobePath:
- raise TaskError("Binary not found: {name}", name="FFmpeg")
+ raise TaskError("{name} 未安装,请在设置中安装", name="FFmpeg")
Path(self.outputFile).parent.mkdir(parents=True, exist_ok=True)
@@ -82,7 +82,7 @@ class FFmpegStep(TaskStep):
if process.returncode != 0:
stderr = (await process.stderr.read()).decode("utf-8", errors="ignore").strip()
raise TaskError(
- "FFmpeg merge failed ({code}): {detail}",
+ "FFmpeg 合并失败({code}):{detail}",
code=process.returncode,
detail=stderr or "unknown error",
)
diff --git a/features/ftp_pack/task.py b/features/ftp_pack/task.py
index f6eb4442..cea95fc1 100644
--- a/features/ftp_pack/task.py
+++ b/features/ftp_pack/task.py
@@ -91,7 +91,7 @@ class FtpConnectionInfo:
scheme, self.host, port, mode, repr(e),
)
- raise TaskError("Cannot establish FTP connection") from lastError
+ raise TaskError("无法建立 FTP 连接") from lastError
@dataclass
diff --git a/features/http_pack/task.py b/features/http_pack/task.py
index 87ba8e6e..ffc88f1e 100644
--- a/features/http_pack/task.py
+++ b/features/http_pack/task.py
@@ -383,7 +383,7 @@ class HttpTaskStep(TaskStep):
except ExceptionGroup as eg:
cause = eg.exceptions[0]
if isinstance(cause, PermanentDownloadError):
- raise TaskError("Server returned error ({status})", status=cause.status) from eg
+ raise TaskError("服务器返回了错误({status})", status=cause.status) from eg
raise cause from eg
finally:
if not supervisor.done():
diff --git a/features/m3u8_pack/task.py b/features/m3u8_pack/task.py
index fee9481b..fe51ee73 100644
--- a/features/m3u8_pack/task.py
+++ b/features/m3u8_pack/task.py
@@ -313,7 +313,7 @@ class M3U8TaskStep(TaskStep):
execPath = m3u8Runtime.path()
if not execPath:
- raise TaskError("Binary not found: {name}", name="N_m3u8DL-RE")
+ raise TaskError("{name} 未安装,请在设置中安装", name="N_m3u8DL-RE")
self.task.outputFolder.mkdir(parents=True, exist_ok=True)
Path(self._tempFolder).mkdir(parents=True, exist_ok=True)
@@ -341,7 +341,7 @@ class M3U8TaskStep(TaskStep):
if self._process.returncode != 0 and not self._stopping:
raise TaskError(
- "Process exited with error ({code}): {detail}",
+ "进程异常退出({code}):{detail}",
code=self._process.returncode,
detail=self.lastMessage or "N_m3u8DL-RE",
)
diff --git a/features/yt_dlp_pack/error_catalog.py b/features/yt_dlp_pack/error_catalog.py
index 0da634e7..1dfe0f50 100644
--- a/features/yt_dlp_pack/error_catalog.py
+++ b/features/yt_dlp_pack/error_catalog.py
@@ -1,10 +1,10 @@
from PySide6.QtCore import QT_TRANSLATE_NOOP as N
-N("TaskErrors", "Video not available in your region, try configuring a proxy")
-N("TaskErrors", "Video unavailable (may be deleted or private)")
-N("TaskErrors", "Private video, requires cookies from an authorized account")
-N("TaskErrors", "Members-only video, requires cookies from a member account")
-N("TaskErrors", "Age-restricted video, requires cookies from a logged-in account")
-N("TaskErrors", "YouTube requires human verification, configure cookies in settings")
-N("TaskErrors", "Requested format not available, try a different quality")
-N("TaskErrors", "Download rejected (403), link may have expired")
+N("TaskErrors", "该视频在您所在地区不可用,请尝试配置代理")
+N("TaskErrors", "视频不可用(可能已被删除或设为私密)")
+N("TaskErrors", "私密视频,需要已授权账号的 Cookie")
+N("TaskErrors", "会员专属视频,需要会员账号的 Cookie")
+N("TaskErrors", "年龄限制视频,需要已登录账号的 Cookie")
+N("TaskErrors", "YouTube 需要人机验证,请在设置中配置 Cookie")
+N("TaskErrors", "请求的格式不可用,请尝试其他画质")
+N("TaskErrors", "下载被拒绝(403),链接可能已失效")
diff --git a/features/yt_dlp_pack/task.py b/features/yt_dlp_pack/task.py
index 5fb3fef1..5062095d 100644
--- a/features/yt_dlp_pack/task.py
+++ b/features/yt_dlp_pack/task.py
@@ -20,14 +20,14 @@ PROGRESS_TEMPLATE = (
FINAL_TEMPLATE = f"after_move:{FINAL_FILE_TOKEN}%(filepath)s"
ERROR_HINTS = (
- ("is not available in your country", "Video not available in your region, try configuring a proxy"),
- ("video unavailable", "Video unavailable (may be deleted or private)"),
- ("private video", "Private video, requires cookies from an authorized account"),
- ("members-only", "Members-only video, requires cookies from a member account"),
- ("confirm your age", "Age-restricted video, requires cookies from a logged-in account"),
- ("confirm you're not a bot", "YouTube requires human verification, configure cookies in settings"),
- ("requested format is not available", "Requested format not available, try a different quality"),
- ("http error 403", "Download rejected (403), link may have expired"),
+ ("is not available in your country", "该视频在您所在地区不可用,请尝试配置代理"),
+ ("video unavailable", "视频不可用(可能已被删除或设为私密)"),
+ ("private video", "私密视频,需要已授权账号的 Cookie"),
+ ("members-only", "会员专属视频,需要会员账号的 Cookie"),
+ ("confirm your age", "年龄限制视频,需要已登录账号的 Cookie"),
+ ("confirm you're not a bot", "YouTube 需要人机验证,请在设置中配置 Cookie"),
+ ("requested format is not available", "请求的格式不可用,请尝试其他画质"),
+ ("http error 403", "下载被拒绝(403),链接可能已失效"),
)
@@ -208,7 +208,7 @@ class YtDlpTaskStep(TaskStep):
async def run(self) -> None:
execPath = ytDlpRuntime.path()
if not execPath:
- raise TaskError("Binary not found: {name}", name="yt-dlp")
+ raise TaskError("{name} 未安装,请在设置中安装", name="yt-dlp")
self._finalPath = ""
self._totalBytes = 0
@@ -233,7 +233,7 @@ class YtDlpTaskStep(TaskStep):
lowered = self.lastMessage.lower()
hint = next((h for needle, h in ERROR_HINTS if needle in lowered), "")
raise TaskError(
- hint or "Process exited with error ({code}): {detail}",
+ hint or "进程异常退出({code}):{detail}",
code=process.returncode,
detail=self.lastMessage or "yt-dlp",
)