The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
refactor: 简化 FFmpeg 功能包
XiaoYouChR0f7aaaf04db6
diff --git a/features/ffmpeg_pack/config.py b/features/ffmpeg_pack/config.pyindex e7a2360a..ef4e000f 100644--- a/features/ffmpeg_pack/config.py+++ b/features/ffmpeg_pack/config.py@@ -152,11 +152,11 @@ class FFmpegRuntimeCard(SettingCard):if sys.platform != "win32":return- from .task import createWindowsInstallTask+ from .task import createInstallTaskself.installButton.setEnabled(False)self.installButton.setText(self.tr("准备中..."))- coreService.runCoroutine(createWindowsInstallTask(), self._onInstallTaskCreated)+ coreService.runCoroutine(createInstallTask(), self._onInstallTaskCreated)def _onInstallTaskCreated(self, result, error: str | None):self.installButton.setEnabled(True)diff --git a/features/ffmpeg_pack/pack.py b/features/ffmpeg_pack/pack.pyindex 1c7fd331..9fec8a73 100644--- a/features/ffmpeg_pack/pack.py+++ b/features/ffmpeg_pack/pack.py@@ -11,7 +11,7 @@ from app.bases.interfaces import FeaturePackfrom app.bases.models import Task, SpecialFileSizefrom app.supports.config import DEFAULT_HEADERS, cfgfrom app.supports.utils import getProxies, sanitizeFilename-from .config import ffmpegConfig, resolveFFmpegExecutables+from .config import _executableName, ffmpegConfig, resolveFFmpegExecutablesfrom .task import FFmpegStageif TYPE_CHECKING:@@ -31,13 +31,6 @@ _FFMPEG_HEADERS = {}-def _executableName(name: str) -> str:- return f"{name}.exe" if sys.platform == "win32" else name---def _normalizePath(path: Path | str) -> str:- return str(Path(path)).replace("\\", "/")-def _resourceExtension(name: str, url: str) -> str:fileName = Path(name).name if name else Path(urlparse(url).path).name@@ -233,7 +226,7 @@ async def createInstallTask() -> Task:downloadStage: HttpTaskStage = downloadTask.stages[0]archiveSize = downloadTask.fileSize if downloadTask.fileSize > 0 else assetInfo["size"]assetName = downloadTask.title or str(assetInfo["name"])- archivePath = _normalizePath(Path(installFolder) / assetName)+ archivePath = str(Path(installFolder) / assetName).replace("\\", "/")downloadStage.stageIndex = 1downloadStage.outputFile = archivePath@@ -255,7 +248,7 @@ async def createInstallTask() -> Task:task.addStage(ExtractStage(stageIndex=2,archivePath=archivePath,- installFolder=_normalizePath(Path(installFolder)),+ installFolder=str(Path(installFolder)).replace("\\", "/"),executableNames=[_executableName("ffmpeg"), _executableName("ffprobe")],))return task@@ -269,7 +262,7 @@ class FFmpegPack(FeaturePack):return str(url).strip() == FFMPEG_MERGE_URLasync def resolve(self, payload: dict) -> dict:- return payload+ return {"_task": await createMergeTask(payload)}def build(self, payload: dict) -> Task:- raise NotImplementedError("Use createMergeTask() for FFmpeg merge tasks")+ return payload["_task"]diff --git a/features/ffmpeg_pack/task.py b/features/ffmpeg_pack/task.pyindex cd3b765b..af0d128d 100644--- a/features/ffmpeg_pack/task.py+++ b/features/ffmpeg_pack/task.py@@ -37,7 +37,7 @@ class FFmpegWorker(Worker):return 0.0return duration if duration > 0 else 0.0- async def _probeDuration(self, ffprobe: str, path: str) -> float:+ async def _getDuration(self, ffprobe: str, path: str) -> float:process = await asyncio.create_subprocess_exec(ffprobe,"-v", "error",@@ -92,7 +92,7 @@ class FFmpegWorker(Worker):self.stage.progress = 0self.stage.speed = 0self.stage.receivedBytes = 0- totalDuration = await self._probeDuration(ffprobe, self.stage.videoPath)+ totalDuration = await self._getDuration(ffprobe, self.stage.videoPath)process = await asyncio.create_subprocess_exec(ffmpeg,"-y", "-v", "error", "-nostats", "-progress", "pipe:1",