The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
feat(sources): yt-dlp PyPI 镜像联动源选择
XiaoYouChRd1a53b9941ac
diff --git a/app/sources.py b/app/sources.pyindex 3e247989..e112e7bd 100644--- a/app/sources.py+++ b/app/sources.py@@ -129,6 +129,19 @@ async def fetchJson(repo: str, branch: str, path: str) -> tuple[dict, str]:raise RuntimeError(f"无法获取 {repo}/{branch}/{path}")+PYPI_MIRRORS = {+ "gitcode": "https://mirrors.bfsu.edu.cn/pypi/web/json",+ "github": "https://pypi.org/pypi",+}+++def buildPypiUrl(package: str, *, source: str) -> str:+ base = PYPI_MIRRORS.get(source, PYPI_MIRRORS["github"])+ if source == "gitcode":+ return f"{base}/{package}"+ return f"{base}/{package}/json"++def buildDownloadUrl(repo: str, tag: str, asset: str, *, source: str) -> str:mapped = GITCODE_REPOS.get(repo, repo) if source == "gitcode" else repoendpoints = SOURCES[source]diff --git a/features/yt_dlp_pack/config.py b/features/yt_dlp_pack/config.pyindex 2004daa8..c4e9c256 100644--- a/features/yt_dlp_pack/config.py+++ b/features/yt_dlp_pack/config.py@@ -17,7 +17,6 @@ from app.models.pack import BinaryRuntime, PackConfig, VersionInfofrom app.platform.android import IS_ANDROIDfrom app.platform.filesystem import findExecutable-PYPI_API = "https://pypi.org/pypi/yt-dlp/json"QJS_REPO = "quickjs-ng/quickjs"COOKIE_DOMAIN = ".youtube.com"AUTH_COOKIE_NAMES = ("LOGIN_INFO", "SAPISID", "__Secure-1PAPISID", "__Secure-3PAPISID")@@ -199,9 +198,11 @@ class YouTubeRuntime(BinaryRuntime):async def fetchLatestVersion(self) -> str:from app.client import buildClient+ from app.sources import SOURCE_ORDER, buildPypiUrl+ url = buildPypiUrl("yt-dlp", source=SOURCE_ORDER[0])client = buildClient(timeout=15)try:- resp = await client.get(PYPI_API)+ resp = await client.get(url)resp.raise_for_status()data = await resp.json()return data.get("info", {}).get("version", "")@@ -274,10 +275,12 @@ class YouTubeRuntime(BinaryRuntime):async def _fetchWhlAsset(self) -> tuple[str, int]:from app.client import buildClient+ from app.sources import SOURCE_ORDER, buildPypiUrl+ url = buildPypiUrl("yt-dlp", source=SOURCE_ORDER[0])client = buildClient(timeout=15)try:- response = await client.get(PYPI_API)+ response = await client.get(url)response.raise_for_status()data = await response.json()finally: