The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix: 修复任务接口重构后的兼容问题
XiaoYouChR9648a67194a8
diff --git a/features/bittorrent_pack/cards.py b/features/bittorrent_pack/cards.pyindex e955a3e0..f1fde996 100644--- a/features/bittorrent_pack/cards.py+++ b/features/bittorrent_pack/cards.py@@ -24,7 +24,7 @@ from app.view.components.cards import ResultCard, UniversalTaskCardfrom app.view.components.dialogs import FileSelectDialogfrom app.view.components.labels import IconBodyLabel-from .task import BitTorrentFile, BitTorrentTask+from .task import BTFile, BTTaskdef _removePath(path: Path):@@ -36,7 +36,7 @@ def _removePath(path: Path):path.unlink(missing_ok=True)-def _openFileSelection(task: BitTorrentTask, parent) -> set[int] | None:+def _openFileSelection(task: BTTask, parent) -> set[int] | None:dialog = TorrentFileSelectDialog(task, parent)try:if not dialog.exec():@@ -49,19 +49,19 @@ def _openFileSelection(task: BitTorrentTask, parent) -> set[int] | None:class TorrentFileSelectDialog(FileSelectDialog):- def __init__(self, task: BitTorrentTask, parent=None):+ def __init__(self, task: BTTask, parent=None):super().__init__(task, parent)- self.task: BitTorrentTask = task+ self.task: BTTask = task- def _fileDisplayPath(self, file: BitTorrentFile) -> str:+ def _fileDisplayPath(self, file: BTFile) -> str:return self.task.mappedRelativePath(file)- def _fileTypePath(self, file: BitTorrentFile) -> str:+ def _fileTypePath(self, file: BTFile) -> str:return file.pathclass BitTorrentResultCard(ResultCard):- def __init__(self, task: BitTorrentTask, parent: QWidget = None):+ def __init__(self, task: BTTask, parent: QWidget = None):super().__init__(task, parent)self.task = task@@ -118,14 +118,14 @@ class BitTorrentResultCard(ResultCard):if _openFileSelection(self.task, self.window()) is not None:self._refreshSummary()- def getTask(self) -> BitTorrentTask:+ def getTask(self) -> BTTask:return self.task-class BitTorrentTaskCard(UniversalTaskCard):- def __init__(self, task: BitTorrentTask, parent=None):+class BTTaskCard(UniversalTaskCard):+ def __init__(self, task: BTTask, parent=None):super().__init__(task, parent)- self.task: BitTorrentTask = task+ self.task: BTTask = taskself.speedLabel.setIcon(FluentIcon.DOWNLOAD)self.uploadRateLabel = IconBodyLabel("", FluentIcon.SHARE, self)self.infoLayout.insertWidget(self.infoLayout.indexOf(self.leftTimeLabel), self.uploadRateLabel)diff --git a/features/bittorrent_pack/pack.py b/features/bittorrent_pack/pack.pyindex c72b098e..2890750b 100644--- a/features/bittorrent_pack/pack.py+++ b/features/bittorrent_pack/pack.py@@ -6,7 +6,7 @@ from app.bases.interfaces import FeaturePackfrom app.bases.models import Taskfrom app.services.core_service import coreService-from .cards import BitTorrentResultCard, BitTorrentTaskCard+from .cards import BitTorrentResultCard, BTTaskCardfrom .config import bittorrentConfig, getCachedWebTrackers, refreshConfiguredWebTrackersfrom .task import BTTask, parse, resolveLocalTorrentPath@@ -48,7 +48,7 @@ class BitTorrentPack(FeaturePack):raise NotImplementedError("Use resolve() for BitTorrent tasks")def taskCard(self, task, parent=None):- return BitTorrentTaskCard(task, parent)+ return BTTaskCard(task, parent)def resultCard(self, task, parent=None):return BitTorrentResultCard(task, parent)diff --git a/features/bittorrent_pack/task.py b/features/bittorrent_pack/task.pyindex 59d8ea13..54cff839 100644--- a/features/bittorrent_pack/task.py+++ b/features/bittorrent_pack/task.py@@ -286,8 +286,8 @@ class BTStage(TaskStage):self.downloadRate = 0self.uploadRate = 0- def reset(self, notifyTask: bool = True):- super().reset(notifyTask=notifyTask)+ def reset(self, sync: bool = True):+ super().reset(sync=sync)self.stateText = ""self.peerCount = 0self.seedCount = 0@@ -295,7 +295,7 @@ class BTStage(TaskStage):self.uploadRate = 0-@dataclass+@dataclass(kw_only=True)class BTTask(Task):sourceType: strtorrentData: strdiff --git a/features/ftp_pack/task.py b/features/ftp_pack/task.pyindex 78f41e3b..874dc6c9 100644--- a/features/ftp_pack/task.py+++ b/features/ftp_pack/task.py@@ -127,14 +127,14 @@ class FtpTaskStage(TaskStage):fileIndex: intremotePath: strfileSize: int- resolvePath: str+ outputFile: strsupportsRange: bool = field(default=True)accelerated: bool = field(default=False)- def setStatus(self, status: TaskStatus, notifyTask: bool = True):+ def setStatus(self, status: TaskStatus, sync: bool = True):if status == TaskStatus.COMPLETED:self.receivedBytes = self.fileSize- super().setStatus(status, notifyTask=notifyTask)+ super().setStatus(status, sync=sync)@dataclass(kw_only=True)@@ -263,8 +263,8 @@ class FtpTask(Task):if stage.status == TaskStatus.COMPLETED:continueif status == TaskStatus.RUNNING and stage.status == TaskStatus.FAILED:- stage.reset(notifyTask=False)- stage.setStatus(status, notifyTask=False)+ stage.reset(sync=False)+ stage.setStatus(status, sync=False)return self.updateStatus()@@ -273,7 +273,7 @@ class FtpTask(Task):file.downloadedBytes = 0file.completed = Falsefor stage in self.stages:- stage.reset(notifyTask=False)+ stage.reset(sync=False)return self.updateStatus()def reopenForAdditionalFiles(self) -> bool:@@ -287,7 +287,7 @@ class FtpTask(Task):return Falsefor stage in pendingSelectedStages:- stage.setStatus(TaskStatus.PAUSED, notifyTask=False)+ stage.setStatus(TaskStatus.PAUSED, sync=False)self._syncFileProgress()self.updateStatus()diff --git a/features/m3u8_pack/cards.py b/features/m3u8_pack/cards.pyindex a5c314d0..f745a71f 100644--- a/features/m3u8_pack/cards.py+++ b/features/m3u8_pack/cards.py@@ -6,12 +6,10 @@ from PySide6.QtGui import QMouseEventfrom PySide6.QtWidgets import QFileIconProvider, QHBoxLayout, QWidgetfrom qfluentwidgets import BodyLabel, ImageLabel, LineEdit, StrongBodyLabel-from app.bases.models import TaskStatus+from app.bases.models import Task, TaskStatusfrom app.supports.utils import getReadableSize, getReadableTimefrom app.view.components.cards import ResultCard, UniversalTaskCard-from .task import M3U8InstallTask, M3U8Task-def _removeFile(path: Path):try:@@ -77,11 +75,11 @@ class M3U8TaskCard(UniversalTaskCard):task = self.task_removeFile(Path(task.outputFolder))- shutil.rmtree(Path(task.tempDir), ignore_errors=True)+ shutil.rmtree(Path(task.metadata.get('tempDir', '')), ignore_errors=True)outputDirectory = Path(task.path)if outputDirectory.exists():- prefix = f"{task.saveName}."+ prefix = f"{task.title}."for candidate in outputDirectory.iterdir():if candidate.name == Path(task.outputFolder).name:continue@@ -94,15 +92,16 @@ class M3U8InstallTaskCard(UniversalTaskCard):if not completely:return- if isinstance(self.task, M3U8InstallTask):- shutil.rmtree(self.task.installFolder, ignore_errors=True)+ installFolder = self.task.metadata.get("installFolder")+ if installFolder:+ shutil.rmtree(installFolder, ignore_errors=True)returnsuper().onTaskDeleted(completely)class M3U8ResultCard(ResultCard):- def __init__(self, task: M3U8Task, parent: QWidget = None):+ def __init__(self, task: Task, parent: QWidget = None):super().__init__(task, parent)self.task = taskself.iconLabel = ImageLabel(self)@@ -133,8 +132,8 @@ class M3U8ResultCard(ResultCard):self.mainLayout.addWidget(self.metaLabel)def _metaText(self) -> str:- manifestText = "DASH" if self.task.manifestType == "mpd" else "HLS"- modeText = self.tr("直播") if self.task.isLive else self.tr("点播")+ manifestText = "DASH" if self.task.metadata.get('manifestType', 'm3u8') == "mpd" else "HLS"+ modeText = self.tr("直播") if self.task.metadata.get('isLive', False) else self.tr("点播")return f"{manifestText} · {modeText}"def _refreshIcon(self):@@ -167,5 +166,5 @@ class M3U8ResultCard(ResultCard):self.filenameEdit.hide()self.filenameLabel.show()- def getTask(self) -> M3U8Task:+ def getTask(self) -> Task:return self.task