The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
refactor: 统一下载工具函数命名
XiaoYouChR3b9bea7a85bc
diff --git a/app/supports/utils.py b/app/supports/utils.pyindex 752a5c42..70a835c1 100644--- a/app/supports/utils.py+++ b/app/supports/utils.py@@ -6,6 +6,7 @@ from pathlib import Pathfrom time import sleepfrom typing import TYPE_CHECKING, Callable+from http.cookiejar import CookieJarfrom niquests.cookies import RequestsCookieJar, cookiejar_from_dictfrom urllib.request import getproxiesfrom PySide6.QtCore import QUrl, Qt, QProcess, QStandardPaths@@ -31,7 +32,7 @@ _WINDOWS_RESERVED_FILENAMES = {}-def _cleanFilenameRaw(value: str) -> str:+def _sanitize(value: str) -> str:candidate = str(value or "")lastSeparator = max(candidate.rfind("/"), candidate.rfind("\\"))if lastSeparator >= 0:@@ -52,10 +53,10 @@ def _cleanFilenameRaw(value: str) -> str:def toSafeFilename(name: str, fallback: str = "file", maxLength: int = 200) -> str:normalizedFallback = ""- candidate = _cleanFilenameRaw(name)+ candidate = _sanitize(name)if not candidate:- normalizedFallback = _cleanFilenameRaw(fallback) or "file"+ normalizedFallback = _sanitize(fallback) or "file"candidate = normalizedFallbackif maxLength > 0 and len(candidate) > maxLength:@@ -72,7 +73,7 @@ def toSafeFilename(name: str, fallback: str = "file", maxLength: int = 200) -> scandidate = candidate.rstrip(". ")if candidate in {"", ".", ".."}:if not normalizedFallback:- normalizedFallback = _cleanFilenameRaw(fallback) or "file"+ normalizedFallback = _sanitize(fallback) or "file"candidate = normalizedFallbackreturn candidate@@ -118,11 +119,13 @@ def getProxies():return {protocol: proxyServer for protocol in _PROXY_PROTOCOLS}-def _parseCookieHeader(cookieHeader: str) -> dict[str, str]:- cookies: dict[str, str] = {}- if not isinstance(cookieHeader, str):- return cookies+def splitCookies(headers: dict[str, str] | None) -> tuple[dict[str, str], "RequestsCookieJar | CookieJar | None"]:+ requestHeaders = dict(headers or {})+ cookieHeader = str(requestHeaders.pop("cookie", "") or "").strip()+ if not cookieHeader:+ return requestHeaders, None+ cookieItems: dict[str, str] = {}for part in cookieHeader.replace("\r", ";").replace("\n", ";").split(";"):part = part.strip()if not part or "=" not in part:@@ -130,48 +133,22 @@ def _parseCookieHeader(cookieHeader: str) -> dict[str, str]:name, value = part.split("=", 1)name = name.strip()- value = value.strip()- if name and value:- cookies[name] = value-- return cookies---def _encodeCookieTransportValue(value: str) -> str:- text = str(value or "").strip()- if not text:- return ""-- if any(ord(char) < 32 or ord(char) == 127 for char in text):- return ""-- if all(ord(char) <= 255 for char in text):- return text-- return text.encode("utf-8").decode("latin-1")+ value = str(value or "").strip()+ if not name or not value:+ continue+ if any(ord(c) < 32 or ord(c) == 127 for c in value):+ continue+ encodedValue = value if all(ord(c) <= 255 for c in value) else value.encode("utf-8").decode("latin-1")+ cookieItems[name] = encodedValue-def splitRequestHeadersAndCookies(headers: dict[str, str] | None) -> tuple[dict[str, str], RequestsCookieJar | None]:- requestHeaders = dict(headers or {})- cookieHeader = str(requestHeaders.pop("cookie", "") or "").strip()- if not cookieHeader:+ if not cookieItems:return requestHeaders, None- parsedCookies = _parseCookieHeader(cookieHeader)- if not parsedCookies:- return requestHeaders, None+ return requestHeaders, cookiejar_from_dict(cookieItems)- cookieItems: dict[str, str] = {}- for name, value in parsedCookies.items():- normalizedName = str(name or "").strip()- normalizedValue = _encodeCookieTransportValue(value)- if normalizedName and normalizedValue:- cookieItems[normalizedName] = normalizedValue- if not cookieItems:- return requestHeaders, None- return requestHeaders, cookiejar_from_dict(cookieItems)def toReadableSize(size: int):diff --git a/features/bittorrent_pack/config.py b/features/bittorrent_pack/config.pyindex 8db2d426..93f7e72f 100644--- a/features/bittorrent_pack/config.py+++ b/features/bittorrent_pack/config.py@@ -29,7 +29,7 @@ from app.services.core_service import coreServicefrom app.supports.config import cfgfrom app.view.components.editors import AutoSizingEditfrom app.view.components.setting_cards import SpinBoxSettingCard-from .trackers import fetchWebTrackers, formatTrackers, normalizeTrackerSource, parseTrackerText+from .trackers import fetchWebTrackers, formatTrackers, toTrackers, parseTrackerTextif TYPE_CHECKING:from app.view.pages.setting_page import SettingPage@@ -40,10 +40,10 @@ DEFAULT_WEB_TRACKER_SOURCE = "https://cf.trackerslist.com/best.txt"class WebTrackerSourceValidator(ConfigValidator):def validate(self, value) -> bool:- return bool(normalizeTrackerSource(str(value or "")))+ return bool(toTrackers(str(value or "")))def correct(self, value) -> str:- source = normalizeTrackerSource(str(value or ""))+ source = toTrackers(str(value or ""))return source or DEFAULT_WEB_TRACKER_SOURCE@@ -64,7 +64,7 @@ def saveCachedWebTrackers(trackers: list[str]):async def refreshConfiguredWebTrackers(sourceUrl: str | None = None) -> list[str]:- source = normalizeTrackerSource(sourceUrl or bittorrentConfig.webTrackerSource.value)+ source = toTrackers(sourceUrl or bittorrentConfig.webTrackerSource.value)if not source:raise ValueError("Web Tracker 源地址无效")trackers = await fetchWebTrackers(source)@@ -97,7 +97,7 @@ class WebTrackerDialog(MessageBoxBase):self.viewLayout.addWidget(self.refreshButton, 0)def _onRefreshClicked(self):- source = normalizeTrackerSource(self.sourceEdit.text())+ source = toTrackers(self.sourceEdit.text())if not source:InfoBar.error(self.tr("源地址无效"), self.tr("请输入有效的 HTTP/HTTPS 地址"), parent=self)return@@ -120,7 +120,7 @@ class WebTrackerDialog(MessageBoxBase):)def validate(self) -> bool:- source = normalizeTrackerSource(self.sourceEdit.text())+ source = toTrackers(self.sourceEdit.text())if not source:InfoBar.error(self.tr("源地址无效"), self.tr("请输入有效的 HTTP/HTTPS 地址"), parent=self)return Falsediff --git a/features/bittorrent_pack/pack.py b/features/bittorrent_pack/pack.pyindex 25b10c8c..d145f948 100644--- a/features/bittorrent_pack/pack.py+++ b/features/bittorrent_pack/pack.py@@ -8,11 +8,11 @@ from app.services.core_service import coreServicefrom .cards import BitTorrentResultCard, BTTaskCardfrom .config import bittorrentConfig, getCachedWebTrackers, refreshConfiguredWebTrackers-from .task import BTTask, resolve as _btResolve, resolveLocalTorrentPath+from .task import BTTask, resolve as _btResolve, loadLocalTorrentdef _isTorrentUrl(url: str) -> bool:- if resolveLocalTorrentPath(url) is not None:+ if loadLocalTorrent(url) is not None:return TrueparsedUrl = urlparse(url)diff --git a/features/bittorrent_pack/task.py b/features/bittorrent_pack/task.pyindex ba6a5896..90a02b41 100644--- a/features/bittorrent_pack/task.py+++ b/features/bittorrent_pack/task.py@@ -15,7 +15,7 @@ from loguru import loggerfrom app.bases.interfaces import Workerfrom app.bases.models import Task, TaskStage, TaskStatusfrom app.supports.config import DEFAULT_HEADERS, VERSION, cfg-from app.supports.utils import getProxies, toSafeFilename, splitRequestHeadersAndCookies+from app.supports.utils import getProxies, toSafeFilename, splitCookiesfrom .config import bittorrentConfig, getCachedWebTrackers, refreshConfiguredWebTrackersfrom .trackers import mergeTrackers@@ -40,7 +40,7 @@ _STATE_TEXT_MAP = {}-def resolveLocalTorrentPath(source: str) -> Path | None:+def loadLocalTorrent(source: str) -> Path | None:text = str(source).strip()if not text:return None@@ -587,7 +587,7 @@ class BTWorker(Worker):async def _loadFromFile(source: str, webTrackers: list[str]) -> tuple[bytes, lt.torrent_info, list[str]]:- torrentPath = resolveLocalTorrentPath(source)+ torrentPath = loadLocalTorrent(source)if torrentPath is None:raise ValueError("不是有效的本地 .torrent 文件路径")torrentBytes = await asyncio.to_thread(lambda: torrentPath.resolve().read_bytes())@@ -599,7 +599,7 @@ async def _loadFromUrl(payload: dict, webTrackers: list[str]) -> tuple[bytes, lturl = str(payload["url"]).strip()headers = payload.get("headers", DEFAULT_HEADERS)proxies = payload.get("proxies", getProxies())- requestHeaders, requestCookies = splitRequestHeadersAndCookies(+ requestHeaders, requestCookies = splitCookies(headers if isinstance(headers, dict) else DEFAULT_HEADERS)@@ -758,7 +758,7 @@ async def resolve(payload: dict) -> BTTask:url = str(payload["url"]).strip()webTrackers = await _fetchTrackers()- localTorrentPath = resolveLocalTorrentPath(url)+ localTorrentPath = loadLocalTorrent(url)if localTorrentPath is not None:torrentBytes, ti, trackers = await _loadFromFile(url, webTrackers)return _buildTask(diff --git a/features/bittorrent_pack/trackers.py b/features/bittorrent_pack/trackers.pyindex 40402a08..a00d0e85 100644--- a/features/bittorrent_pack/trackers.py+++ b/features/bittorrent_pack/trackers.py@@ -9,7 +9,7 @@ from app.supports.utils import getProxies_TRACKER_SCHEMES = {"http", "https", "udp", "ws", "wss"}-def normalizeTrackerSource(source: str) -> str:+def toTrackers(source: str) -> str:value = str(source or "").strip()if not value:return ""@@ -47,7 +47,7 @@ def mergeTrackers(*trackerGroups: list[str]) -> list[str]:async def fetchWebTrackers(sourceUrl: str) -> list[str]:- normalizedSource = normalizeTrackerSource(sourceUrl)+ normalizedSource = toTrackers(sourceUrl)if not normalizedSource:raise ValueError("Web Tracker 源地址无效")diff --git a/features/extract_pack/task.py b/features/extract_pack/task.pyindex ddaff046..4aefef2c 100644--- a/features/extract_pack/task.py+++ b/features/extract_pack/task.py@@ -9,11 +9,10 @@ from pathlib import Pathfrom time import perf_counterfrom app.bases.interfaces import Worker+from app.supports.utils import toPosixPathfrom app.bases.models import Task, TaskStage, TaskStatus-def _normalizePath(path: Path | str) -> str:- return str(Path(path)).replace("\\", "/")def _archiveSuffix(name: str) -> str:@@ -190,7 +189,7 @@ class ExtractWorker(Worker):if sys.platform != "win32":executablePath.chmod(executablePath.stat().st_mode | 0o755)- executables[name] = _normalizePath(executablePath)+ executables[name] = toPosixPath(executablePath)return executablesdiff --git a/features/ffmpeg_pack/config.py b/features/ffmpeg_pack/config.pyindex 1c04f7cc..10ac2fa7 100644--- a/features/ffmpeg_pack/config.py+++ b/features/ffmpeg_pack/config.py@@ -32,7 +32,7 @@ def _guessInstallRoot(ffmpegPath: str) -> str:return toPosixPath(path.parent)-def _resolveExecutable(name: str) -> str:+def _findExecutable(name: str) -> str:installFolder = Path(ffmpegConfig.installFolder.value)for candidate in (installFolder / "bin" / toExecutable(name), installFolder / toExecutable(name)):if candidate.is_file():@@ -42,12 +42,12 @@ def _resolveExecutable(name: str) -> str:return toPosixPath(found) if found else ""-def resolveFFmpegExecutables() -> tuple[str, str]:- return _resolveExecutable("ffmpeg"), _resolveExecutable("ffprobe")+def ffmpegPaths() -> tuple[str, str]:+ return _findExecutable("ffmpeg"), _findExecutable("ffprobe")async def queryFFmpegRuntime() -> dict[str, str]:- ffmpegPath, ffprobePath = resolveFFmpegExecutables()+ ffmpegPath, ffprobePath = ffmpegPaths()runtimeInfo = {"ffmpegPath": ffmpegPath,"ffprobePath": ffprobePath,diff --git a/features/ffmpeg_pack/pack.py b/features/ffmpeg_pack/pack.pyindex 1aa1b2c6..f888f9fc 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, toExecutable, toPosixPath, toSafeFilename-from .config import ffmpegConfig, resolveFFmpegExecutables+from .config import ffmpegConfig, ffmpegPathsfrom .task import FFmpegStageif TYPE_CHECKING:@@ -119,7 +119,7 @@ async def _requestLatestReleaseAsset() -> dict[str, Any]:async def createMergeTask(payload: dict[str, Any], title: str = "") -> Task:- ffmpeg, ffprobe = resolveFFmpegExecutables()+ ffmpeg, ffprobe = ffmpegPaths()if not ffmpeg or not ffprobe:raise RuntimeError("未找到可用的 ffmpeg 和 ffprobe,请先在设置中安装或配置 FFmpeg")diff --git a/features/ffmpeg_pack/task.py b/features/ffmpeg_pack/task.pyindex bea33ce1..b6437d55 100644--- a/features/ffmpeg_pack/task.py+++ b/features/ffmpeg_pack/task.py@@ -7,7 +7,7 @@ from loguru import loggerfrom app.bases.interfaces import Workerfrom app.bases.models import TaskStage, TaskStatus-from .config import resolveFFmpegExecutables+from .config import ffmpegPaths@dataclass(kw_only=True)@@ -79,7 +79,7 @@ class FFmpegWorker(Worker):self.stage.progress = 100async def run(self):- ffmpeg, ffprobe = resolveFFmpegExecutables()+ ffmpeg, ffprobe = ffmpegPaths()if not ffmpeg or not ffprobe:raise RuntimeError("未找到可用的 ffmpeg 和 ffprobe,请先在设置中安装或配置 FFmpeg")diff --git a/features/http_pack/pack.py b/features/http_pack/pack.pyindex 01be92c5..dc386adc 100644--- a/features/http_pack/pack.py+++ b/features/http_pack/pack.py@@ -11,11 +11,11 @@ from loguru import loggerfrom app.bases.interfaces import FeaturePackfrom app.bases.models import Task, SpecialFileSizefrom app.supports.config import cfg, DEFAULT_HEADERS-from app.supports.utils import getProxies, toSafeFilename, splitRequestHeadersAndCookies+from app.supports.utils import getProxies, toSafeFilename, splitCookiesfrom .task import HttpTaskStage-def _parsePositiveContentLength(headers: dict[str, str]) -> int:+def _contentLength(headers: dict[str, str]) -> int:value = headers.get("content-length", "").strip()if not value:return SpecialFileSize.UNKNOWN@@ -28,7 +28,7 @@ def _parsePositiveContentLength(headers: dict[str, str]) -> int:return length if length > 0 else SpecialFileSize.UNKNOWN-def _parseContentRangeTotal(headers: dict[str, str]) -> int:+def _rangeSize(headers: dict[str, str]) -> int:contentRange = headers.get("content-range", "").strip()if not contentRange or "/" not in contentRange:return SpecialFileSize.UNKNOWN@@ -45,15 +45,9 @@ def _parseContentRangeTotal(headers: dict[str, str]) -> int:return size if size > 0 else SpecialFileSize.UNKNOWN-def _buildRangeProbeHeaders(headers: dict, rangeValue: str) -> dict:- requestHeaders = headers.copy()- requestHeaders["range"] = rangeValue- requestHeaders["accept-encoding"] = "identity"- return requestHeaders--async def _requestProbe(client: niquests.AsyncSession, url: str, headers: dict, proxies: dict) -> tuple[int, dict[str, str], str]:- requestHeaders, requestCookies = splitRequestHeadersAndCookies(headers)+async def _sendProbe(client: niquests.AsyncSession, url: str, headers: dict, proxies: dict) -> tuple[int, dict[str, str], str]:+ requestHeaders, requestCookies = splitCookies(headers)response = await client.get(url,headers=requestHeaders,@@ -72,19 +66,19 @@ async def _requestProbe(client: niquests.AsyncSession, url: str, headers: dict,await response.close()-async def _probeDownloadInfo(url: str, headers: dict, proxies: dict) -> tuple[int, bool, str, dict[str, str]]:+async def _probe(url: str, headers: dict, proxies: dict) -> tuple[int, bool, str, dict[str, str]]:client = niquests.AsyncSession(happy_eyeballs=True)client.trust_env = Falsetry:- statusCode, responseHeaders, finalUrl = await _requestProbe(+ statusCode, responseHeaders, finalUrl = await _sendProbe(client,url,- _buildRangeProbeHeaders(headers, "bytes=1-1"),+ {**headers, "range": "bytes=1-1", "accept-encoding": "identity"},proxies,)- fileSize = _parseContentRangeTotal(responseHeaders)+ fileSize = _rangeSize(responseHeaders)supportsRange = statusCode == 206 and "content-range" in responseHeadersif supportsRange:@@ -92,28 +86,28 @@ async def _probeDownloadInfo(url: str, headers: dict, proxies: dict) -> tuple[inresponseHeaders.get("content-range", ""), fileSize)return fileSize, True, finalUrl, responseHeaders- fileSize = _parsePositiveContentLength(responseHeaders)+ fileSize = _contentLength(responseHeaders)if statusCode == 200:logger.info("偏移 Range 探测返回 200, content-length: {}",responseHeaders.get("content-length", ""))if fileSize in {SpecialFileSize.UNKNOWN, 1}:- fallbackStatus, fallbackHeaders, _ = await _requestProbe(+ fallbackStatus, fallbackHeaders, _ = await _sendProbe(client,url,- _buildRangeProbeHeaders(headers, "bytes=0-0"),+ {**headers, "range": "bytes=0-0", "accept-encoding": "identity"},proxies,)- fallbackSize = _parseContentRangeTotal(fallbackHeaders)+ fallbackSize = _rangeSize(fallbackHeaders)if fallbackStatus == 206 and "content-range" in fallbackHeaders:logger.info("回退 Range 探测成功, content-range: {}, fileSize: {}",fallbackHeaders.get("content-range", ""), fallbackSize)return fallbackSize, True, finalUrl, fallbackHeadersif fileSize == SpecialFileSize.UNKNOWN:- fileSize = _parsePositiveContentLength(fallbackHeaders)+ fileSize = _contentLength(fallbackHeaders)if fileSize == SpecialFileSize.UNKNOWN and fallbackStatus == 416:- fileSize = _parseContentRangeTotal(fallbackHeaders)+ fileSize = _rangeSize(fallbackHeaders)if fileSize == SpecialFileSize.UNKNOWN:logger.info("文件大小未知,按不支持断点续传处理")@@ -125,7 +119,7 @@ async def _probeDownloadInfo(url: str, headers: dict, proxies: dict) -> tuple[inawait client.close()-def _extractFileName(url: str, headers: dict) -> str:+def _fileName(url: str, headers: dict) -> str:fileName = ""cd = headers.get("content-disposition", "")@@ -191,8 +185,8 @@ class HttpPack(FeaturePack):headers: dict = payload.get("headers", DEFAULT_HEADERS)proxies: dict = payload.get("proxies", getProxies())- fileSize, supportsRange, finalUrl, head = await _probeDownloadInfo(url, headers, proxies)- fileName = _extractFileName(finalUrl, head)+ fileSize, supportsRange, finalUrl, head = await _probe(url, headers, proxies)+ fileName = _fileName(finalUrl, head)return {**payload,diff --git a/features/http_pack/task.py b/features/http_pack/task.pyindex 5f03d064..1f984a97 100644--- a/features/http_pack/task.py+++ b/features/http_pack/task.py@@ -13,7 +13,7 @@ from app.bases.interfaces import Workerfrom app.bases.models import TaskStage, TaskStatus, SpecialFileSizefrom app.supports.config import cfgfrom app.supports.sysio import ftruncate, pwrite-from app.supports.utils import splitRequestHeadersAndCookies+from app.supports.utils import splitCookies@dataclass(kw_only=True)@@ -50,7 +50,7 @@ class HttpWorker(Worker):self.stage = stageself.speedHistory = []self.accelCheckTime = 0- self.requestHeaders, self.requestCookies = splitRequestHeadersAndCookies(stage.headers)+ self.requestHeaders, self.requestCookies = splitCookies(stage.headers)def reassignSubworker(self):if self.stage.fileSize <= 0:diff --git a/features/m3u8_pack/config.py b/features/m3u8_pack/config.pyindex c82c9456..537b09d3 100644--- a/features/m3u8_pack/config.py+++ b/features/m3u8_pack/config.py@@ -37,12 +37,12 @@ if TYPE_CHECKING:from app.view.windows.main_window import MainWindowtry:- from ffmpeg_pack.config import resolveFFmpegExecutables+ from ffmpeg_pack.config import ffmpegPathsexcept ImportError:- from features.ffmpeg_pack.config import resolveFFmpegExecutables+ from features.ffmpeg_pack.config import ffmpegPaths-def resolveDownloaderPath() -> str:+def downloaderPath() -> str:installFolder = Path(m3u8Config.installFolder.value)candidate = installFolder / toExecutable("N_m3u8DL-RE")if candidate.is_file():@@ -55,8 +55,8 @@ def resolveDownloaderPath() -> str:async def queryM3U8Runtime() -> dict[str, str]:- downloaderPath = resolveDownloaderPath()- ffmpegPath, _ = resolveFFmpegExecutables()+ downloaderPath = downloaderPath()+ ffmpegPath, _ = ffmpegPaths()runtimeInfo = {"downloaderPath": downloaderPath,"version": "",diff --git a/features/m3u8_pack/pack.py b/features/m3u8_pack/pack.pyindex 3c1cb97d..3213f465 100644--- a/features/m3u8_pack/pack.py+++ b/features/m3u8_pack/pack.py@@ -6,7 +6,7 @@ import niquestsfrom app.bases.interfaces import FeaturePackfrom app.bases.models import Taskfrom app.supports.config import DEFAULT_HEADERS, cfg-from app.supports.utils import getProxies, splitRequestHeadersAndCookies, toPosixPath+from app.supports.utils import getProxies, splitCookies, toPosixPathfrom .config import m3u8Configfrom .task import M3U8TaskStage, _isLive, _manifestType, _stem, _title@@ -27,7 +27,7 @@ class M3U8Pack(FeaturePack):url = str(payload["url"]).strip()headers = payload.get("headers", DEFAULT_HEADERS)proxies = payload.get("proxies", getProxies())- requestHeaders, requestCookies = splitRequestHeadersAndCookies(+ requestHeaders, requestCookies = splitCookies(headers if isinstance(headers, dict) else DEFAULT_HEADERS)diff --git a/features/m3u8_pack/task.py b/features/m3u8_pack/task.pyindex 7c14eb4c..bd72def4 100644--- a/features/m3u8_pack/task.py+++ b/features/m3u8_pack/task.py@@ -16,15 +16,15 @@ from app.bases.interfaces import Workerfrom app.bases.models import Task, TaskStage, TaskStatusfrom app.supports.config import DEFAULT_HEADERS, cfgfrom app.supports.utils import getProxies, toBytes, toExecutable, toPosixPath, toSafeFilename-from .config import m3u8Config, resolveDownloaderPath+from .config import m3u8Config, downloaderPathif TYPE_CHECKING:- from features.ffmpeg_pack.config import resolveFFmpegExecutables+ from features.ffmpeg_pack.config import ffmpegPathsfrom features.http_pack.task import HttpTaskStagefrom features.extract_pack.task import ExtractStageelse:from extract_pack.task import ExtractStage- from ffmpeg_pack.config import resolveFFmpegExecutables+ from ffmpeg_pack.config import ffmpegPathsfrom http_pack.task import HttpTaskStage@@ -160,7 +160,7 @@ class M3U8Worker(Worker):if proxyUrl:args.append(f"--custom-proxy={proxyUrl}")- ffmpegPath, _ = resolveFFmpegExecutables()+ ffmpegPath, _ = ffmpegPaths()if ffmpegPath:args.append(f"--ffmpeg-binary-path={ffmpegPath}")@@ -275,8 +275,8 @@ class M3U8Worker(Worker):self.task.setTitle(found.name)async def run(self):- downloaderPath = resolveDownloaderPath()- if not downloaderPath:+ execPath = downloaderPath()+ if not execPath:raise RuntimeError("未找到可用的 N_m3u8DL-RE,请先在设置中安装或配置运行时")self.task.path.mkdir(parents=True, exist_ok=True)@@ -285,11 +285,11 @@ class M3U8Worker(Worker):process = NonesupervisorTask = Nonetry:- args = self._buildArgs(downloaderPath)+ args = self._buildArgs(execPath)process = await asyncio.create_subprocess_exec(- downloaderPath,+ execPath,*args,- cwd=str(Path(downloaderPath).parent),+ cwd=str(Path(execPath).parent),stdin=asyncio.subprocess.DEVNULL,stdout=asyncio.subprocess.PIPE,stderr=asyncio.subprocess.STDOUT,