The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(sources): Repo 显式声明可用 source,安装失败展示实际原因
XiaoYouChR4700bddbec67
diff --git a/app/sources.py b/app/sources.pyindex 32e5b2b8..9b5bf20b 100644--- a/app/sources.py+++ b/app/sources.py@@ -17,8 +17,13 @@ class Repo:name: strmirrors: dict[str, str] = field(default_factory=dict)- def forSource(self, source: str) -> str:- return self.mirrors.get(source, self.name)+ def nameOn(self, source: str) -> str | None:+ if source == "github":+ return self.name+ return self.mirrors.get(source)++ def buildSources(self) -> list[str]:+ return [s for s in SOURCE_ORDER if self.nameOn(s) is not None]@dataclass(frozen=True)@@ -97,7 +102,7 @@ class Release:async def fetchLatestRelease(repo: Repo) -> Release:async def attempt(source):endpoints = SOURCES[source]- url = f"{endpoints.api}/{repo.forSource(source)}/releases/latest"+ url = f"{endpoints.api}/{repo.nameOn(source)}/releases/latest"headers = {"accept": "application/vnd.github+json"} if source == "github" else {}client = buildClient(headers=headers, timeout=15)try:@@ -111,8 +116,9 @@ async def fetchLatestRelease(repo: Repo) -> Release:finally:client.close()+ sources = repo.buildSources()results = await asyncio.gather(- *[attempt(s) for s in SOURCE_ORDER], return_exceptions=True)+ *[attempt(s) for s in sources], return_exceptions=True)chosen: Release | None = Nonefor result in results:if isinstance(result, BaseException):@@ -133,7 +139,7 @@ async def fetchLatestRelease(repo: Repo) -> Release:async def fetchJson(repo: Repo, branch: str, path: str) -> tuple[dict, str]:async def attempt(source):endpoints = SOURCES[source]- url = f"{endpoints.raw}/{repo.forSource(source)}{endpoints.rawInfix}{branch}/{path}"+ url = f"{endpoints.raw}/{repo.nameOn(source)}{endpoints.rawInfix}{branch}/{path}"client = buildClient(timeout=15)try:resp = await client.get(url)@@ -147,7 +153,7 @@ async def fetchJson(repo: Repo, branch: str, path: str) -> tuple[dict, str]:client.close()result, index, _ = await staggered_race(- [lambda s=s: attempt(s) for s in SOURCE_ORDER], STAGGER_DELAY)+ [lambda s=s: attempt(s) for s in repo.buildSources()], STAGGER_DELAY)if index is not None:return resultraise RuntimeError(f"无法获取 {repo.name}/{branch}/{path}")@@ -159,7 +165,7 @@ async def fetchRawFile() -> str:async def probe(source):endpoints = SOURCES[source]- url = f"{endpoints.raw}/{repo.forSource(source)}{endpoints.rawInfix}{branch}/{path}"+ url = f"{endpoints.raw}/{repo.nameOn(source)}{endpoints.rawInfix}{branch}/{path}"client = buildClient(headers={"Range": "bytes=0-0"}, timeout=10)try:resp = await client.get(url)@@ -175,7 +181,7 @@ async def fetchRawFile(client.close()result, index, _ = await staggered_race(- [lambda s=s: probe(s) for s in SOURCE_ORDER], STAGGER_DELAY)+ [lambda s=s: probe(s) for s in repo.buildSources()], STAGGER_DELAY)if index is None:raise RuntimeError(f"无法下载 {repo.name}/{branch}/{path}")url, source = result@@ -201,7 +207,7 @@ async def probeDownloadUrl(repo: Repo, tag: str, asset: str) -> str:client.close()result, index, _ = await staggered_race(- [lambda s=s: probe(s) for s in SOURCE_ORDER], STAGGER_DELAY)+ [lambda s=s: probe(s) for s in repo.buildSources()], STAGGER_DELAY)if index is None:raise RuntimeError(f"无法下载 {repo.name}/{tag}/{asset}")return result@@ -252,9 +258,9 @@ async def fetchPypiJson(package: str) -> dict:def buildDownloadUrl(repo: Repo, tag: str, asset: str, *, source: str) -> str:endpoints = SOURCES[source]- return f"{endpoints.download}/{repo.forSource(source)}/releases/download/{tag}/{asset}"+ return f"{endpoints.download}/{repo.nameOn(source)}/releases/download/{tag}/{asset}"def buildRawUrl(repo: Repo, branch: str, path: str, *, source: str) -> str:endpoints = SOURCES[source]- return f"{endpoints.raw}/{repo.forSource(source)}{endpoints.rawInfix}{branch}/{path}"+ return f"{endpoints.raw}/{repo.nameOn(source)}{endpoints.rawInfix}{branch}/{path}"diff --git a/app/update.py b/app/update.pyindex d9e61dec..11543d56 100644--- a/app/update.py+++ b/app/update.py@@ -7,7 +7,7 @@ from PySide6.QtCore import QVersionNumberfrom app.sources import Release, ReleaseAsset, Repo, fetchLatestRelease, probeDownloadUrl-APP_REPO = Repo("XiaoYouChR/Ghost-Downloader-3")+APP_REPO = Repo("XiaoYouChR/Ghost-Downloader-3", mirrors={"gitcode": "XiaoYouChR/Ghost-Downloader-3"})def isNewer(current: str, latest: str) -> bool:diff --git a/app/view/components/setting_cards.py b/app/view/components/setting_cards.pyindex fe0d7027..5dacd0c8 100644--- a/app/view/components/setting_cards.py+++ b/app/view/components/setting_cards.py@@ -878,7 +878,7 @@ class RuntimeCard(SettingCard):self.cancelButton.hide()if status.error:- self.setContent(self.tr("检测运行时失败"))+ self.setContent(status.error)elif isInstalled:versionDisplay = status.versionif status.detail:diff --git a/features/ed2k_pack/config.py b/features/ed2k_pack/config.pyindex 8e8f3832..795eaf06 100644--- a/features/ed2k_pack/config.py+++ b/features/ed2k_pack/config.py@@ -14,7 +14,7 @@ from app.platform.filesystem import toPosixPathfrom app.sources import Repo, fetchLatestRelease, probeDownloadUrlfrom .task import ED2kInstallStep-ED2K_REPO = Repo("XiaoYouChR/Python-eD2k")+ED2K_REPO = Repo("XiaoYouChR/Python-eD2k", mirrors={"gitcode": "XiaoYouChR/Python-eD2k"})class ED2kConfig(PackConfig):diff --git a/features/ffmpeg_pack/config.py b/features/ffmpeg_pack/config.pyindex 0a8f17d7..50c9bdc4 100644--- a/features/ffmpeg_pack/config.py+++ b/features/ffmpeg_pack/config.py@@ -17,7 +17,7 @@ from app.sources import Repo, fetchLatestRelease, probeDownloadUrlfrom app.install import createInstallTask-FFMPEG_REPO = Repo("XiaoYouChR/Ghost-Downloader-FFmpeg")+FFMPEG_REPO = Repo("XiaoYouChR/Ghost-Downloader-FFmpeg", mirrors={"gitcode": "XiaoYouChR/Ghost-Downloader-FFmpeg"})def ffmpegAssetTarget() -> str: