The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
refactor(i18n): model stores key, View owns display labels
XiaoYouChRc98d2cb33a4d
diff --git a/features/bittorrent_pack/cards.py b/features/bittorrent_pack/cards.pyindex 71f6b253..fd686bab 100644--- a/features/bittorrent_pack/cards.py+++ b/features/bittorrent_pack/cards.py@@ -1,3 +1,4 @@+from PySide6.QtCore import QT_TRANSLATE_NOOP as Nfrom PySide6.QtWidgets import QFileIconProviderfrom qfluentwidgets import FluentIcon@@ -38,6 +39,24 @@ BT_UPLOAD_FIELD = FieldSpec("upload", FluentIcon.SHARE, {BT_ETA_FIELD = FieldSpec("eta", FluentIcon.STOP_WATCH, {TaskStatus.RUNNING: toBtEtaText})BT_SIZE_FIELD = FieldSpec("size", FluentIcon.LIBRARY, {None: toBtSizeText})+BT_STATE_LABELS = {+ "checking_files": N("BTTaskCard", "校验已有文件"),+ "checking_resume_data": N("BTTaskCard", "检查续传状态"),+ "downloading_metadata": N("BTTaskCard", "获取元数据"),+ "downloading": N("BTTaskCard", "下载中"),+ "finished": N("BTTaskCard", "下载完成"),+ "seeding": N("BTTaskCard", "做种中"),+ "allocating": N("BTTaskCard", "分配文件中"),+ "queued_for_checking": N("BTTaskCard", "等待校验"),+ "paused_seeding": N("BTTaskCard", "已暂停做种"),+ "paused_downloading": N("BTTaskCard", "已暂停下载"),+}++SILENT_STATES = frozenset({+ "downloading", "seeding", "checking_resume_data", "checking_files",+ "downloading_metadata", "allocating", "queued_for_checking", "finished",+})+class BTDraftCard(MultiFileDraftCard):fileSelectDialog = TorrentFileSelectDialog@@ -70,16 +89,17 @@ class BTTaskCard(MultiFileTaskCard):if task.peerCount > 0:parts.append(self.tr("{0} peers").format(task.peerCount))self._setStatus(self.tr("做种中") + " " + " · ".join(parts))- elif task.status == TaskStatus.RUNNING and task.stateText and task.stateText != "下载中":+ elif task.status == TaskStatus.RUNNING and task.stateText and task.stateText != "downloading":self.progressBar.hide()- self._setStatus(self.tr(task.stateText))+ label = BT_STATE_LABELS.get(task.stateText)+ if label:+ self._setStatus(self.tr(label))elif task.status != TaskStatus.RUNNING:parts = []- if task.stateText and task.stateText not in (- "下载中", "做种中", "检查续传状态", "校验已有文件",- "获取元数据", "分配文件中", "等待校验", "下载完成",- ):- parts.append(self.tr(task.stateText))+ if task.stateText and task.stateText not in SILENT_STATES:+ label = BT_STATE_LABELS.get(task.stateText)+ if label:+ parts.append(self.tr(label))if task.shareRatioPercent > 0:parts.append(self.tr("分享率 {0}").format(f"{task.shareRatioPercent:.1f}%"))if task.seedingTimeSeconds > 0:diff --git a/features/bittorrent_pack/session.py b/features/bittorrent_pack/session.pyindex 0c663001..be929927 100644--- a/features/bittorrent_pack/session.py+++ b/features/bittorrent_pack/session.py@@ -20,17 +20,6 @@ from .config import bittorrentConfigif TYPE_CHECKING:pass-_STATE_TEXT = {- "checking_files": "校验已有文件",- "checking_resume_data": "检查续传状态",- "downloading_metadata": "获取元数据",- "downloading": "下载中",- "finished": "下载完成",- "seeding": "做种中",- "allocating": "分配文件中",- "queued_for_checking": "等待校验",-}-DHT_BOOTSTRAP_NODES = ("router.bittorrent.com:6881, router.utorrent.com:6881, ""dht.transmissionbt.com:6881, dht.libtorrent.org:25401"@@ -457,7 +446,7 @@ class BTSession(QObject):def _updateEntry(self, entry: ActiveTorrent) -> None:status = entry.handle.status()- stateText = _STATE_TEXT.get(status.state.name, status.state.name)+ stateText = status.state.nameisSeeding = status.is_seedingdownloadRate = status.download_rateuploadRate = status.upload_ratediff --git a/features/bittorrent_pack/state_catalog.py b/features/bittorrent_pack/state_catalog.pydeleted file mode 100644index cdf666cd..00000000--- a/features/bittorrent_pack/state_catalog.py+++ /dev/null@@ -1,12 +0,0 @@-from PySide6.QtCore import QT_TRANSLATE_NOOP as N--N("BTTaskCard", "校验已有文件")-N("BTTaskCard", "检查续传状态")-N("BTTaskCard", "获取元数据")-N("BTTaskCard", "下载中")-N("BTTaskCard", "下载完成")-N("BTTaskCard", "做种中")-N("BTTaskCard", "分配文件中")-N("BTTaskCard", "等待校验")-N("BTTaskCard", "已暂停做种")-N("BTTaskCard", "已暂停下载")diff --git a/features/bittorrent_pack/task.py b/features/bittorrent_pack/task.pyindex 2d4fd2d6..582db04a 100644--- a/features/bittorrent_pack/task.py+++ b/features/bittorrent_pack/task.py@@ -205,7 +205,7 @@ class BTTaskStep(TaskStep):cached = btSession.lastResumeData(task.taskId)if cached:task.resumeData = b64encode(cached).decode()- task.stateText = "已暂停做种" if task.isSeeding else "已暂停下载"+ task.stateText = "paused_seeding" if task.isSeeding else "paused_downloading"task.isSeeding = Falseraiseexcept Exception:diff --git a/features/yt_dlp_pack/cards.py b/features/yt_dlp_pack/cards.pyindex f0f14023..5b75b4ba 100644--- a/features/yt_dlp_pack/cards.py+++ b/features/yt_dlp_pack/cards.py@@ -2,7 +2,7 @@ from __future__ import annotationsfrom pathlib import Path-from PySide6.QtCore import QCoreApplication, Qt+from PySide6.QtCore import QCoreApplication, Qt, QT_TRANSLATE_NOOP as Nfrom PySide6.QtGui import QColor, QStandardItem, QStandardItemModelfrom PySide6.QtWidgets import QAbstractItemView, QHBoxLayout, QHeaderView, QWidgetfrom qfluentwidgets import (@@ -144,11 +144,11 @@ def buildSubtitleChoices(mediaInfo: dict, automaticLabel: str) -> tuple[list[tupSTEP_LABELS = {- 1: "提取信息",- 2: "下载视频",- 3: "下载音频",- 4: "合并",- 5: "下载字幕",+ 1: N("YtDlpTaskCard", "提取信息"),+ 2: N("YtDlpTaskCard", "下载视频"),+ 3: N("YtDlpTaskCard", "下载音频"),+ 4: N("YtDlpTaskCard", "合并"),+ 5: N("YtDlpTaskCard", "下载字幕"),}diff --git a/features/yt_dlp_pack/label_catalog.py b/features/yt_dlp_pack/label_catalog.pydeleted file mode 100644index 78dfe80e..00000000--- a/features/yt_dlp_pack/label_catalog.py+++ /dev/null@@ -1,7 +0,0 @@-from PySide6.QtCore import QT_TRANSLATE_NOOP as N--N("YtDlpTaskCard", "提取信息")-N("YtDlpTaskCard", "下载视频")-N("YtDlpTaskCard", "下载音频")-N("YtDlpTaskCard", "合并")-N("YtDlpTaskCard", "下载字幕")