Skip to content

The only downloader you need. 下载器的集大成者。

feat(ci): 多平台构建工作流与项目配置

XiaoYouChRa83e24f7bff6
diff --git a/.github/assets/banner.webp b/.github/assets/banner.webp
new file mode 100644
index 00000000..7a76e550
Binary files /dev/null and b/.github/assets/banner.webp differ
diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
index 3893fe95..c273a14a 100644
--- a/.github/workflows/android.yml
+++ b/.github/workflows/android.yml
@@ -14,14 +14,14 @@ permissions:
jobs:
build-android:
runs-on: ubuntu-latest
- timeout-minutes: 90
+ timeout-minutes: 120
env:
GD3_CN_MIRROR: ${{ inputs.use_cn_mirror && '1' || '' }}
GD3_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
GD3_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
- name: Free disk space
run: |
@@ -49,7 +49,7 @@ jobs:
run: ls -la dist/ 2>/dev/null || echo "no dist/"
- name: Upload APK
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v6
with:
name: ghost-downloader-android
path: android/dist/*.apk
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3f6ce9cc..f2d20b0e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -44,7 +44,7 @@ jobs:
runs-on: windows-2022
steps:
- name: Checkout
- uses: actions/checkout@v6
+ uses: actions/checkout@v7
with:
fetch-depth: 0
@@ -59,12 +59,12 @@ jobs:
- name: Build with Nuitka
run: |
- python -c "from app.supports.config import VERSION; f = open('version.txt', 'w'); f.write(VERSION); f.close(); f = open('Ghost-Downloader-3.iss', 'r+'); _ = f.read().replace('APPLICATION_VERSION', VERSION); f.seek(0); f.write(_); f.truncate(); f.close();"
+ python -c "from app.config.constants import VERSION; f = open('version.txt', 'w'); f.write(VERSION); f.close(); f = open('scripts/Ghost-Downloader-3.iss', 'r+'); _ = f.read().replace('APPLICATION_VERSION', VERSION); f.seek(0); f.write(_); f.truncate(); f.close();"
$VERSION = gc version.txt
Write-Host "VERSION=$VERSION"
echo "VERSION=$VERSION" >> $env:GITHUB_ENV
del version.txt
- python deploy.py
+ python scripts/deploy.py
- name: Prepare For Sign
if: ${{ github.event_name == 'release' || github.event.inputs.sign_artifact == 'true' }}
@@ -74,14 +74,14 @@ jobs:
- name: upload-unsigned-artifact
if: ${{ github.event_name == 'release' || github.event.inputs.sign_artifact == 'true' }}
id: upload-unsigned-artifact
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}-Unsigned
path: dist/Ghost-Downloader-3-Unsigned.dist
- name: Sign
if: ${{ github.event_name == 'release' || github.event.inputs.sign_artifact == 'true' }}
- uses: signpath/[email protected]
+ uses: signpath/github-action-submit-signing-request@v2
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '${{ secrets.SIGNPATH_ORGANIZATION_ID }}'
@@ -99,9 +99,9 @@ jobs:
- name: Build Installer
if: ${{ github.event_name == 'release' || github.event.inputs.package_installer == 'true' }}
- uses: Minionguyjpro/[email protected]
+ uses: Minionguyjpro/[email protected]
with:
- path: Ghost-Downloader-3.iss
+ path: scripts/Ghost-Downloader-3.iss
- name: Rename Installer
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.package_installer == 'true' }}
@@ -111,7 +111,7 @@ jobs:
- name: Upload Installer
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.package_installer == 'true' }}
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}-Setup
path: dist/Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}-Setup.exe
@@ -127,19 +127,19 @@ jobs:
Write-Output "Zipping contents of $distPath..."
7z a -tzip -mx=9 -m0=LZMA Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}.zip dist/Ghost-Downloader-3.dist/*
Write-Output "Zip created at $zipFile"
-
+
mv dist/Ghost-Downloader-v${{ env.VERSION }}-Windows-Setup.exe dist/Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}-Setup.exe
- name: Upload artifacts
if: ${{ github.event_name == 'workflow_dispatch' }}
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}
path: |
dist/Ghost-Downloader-3.dist
- name: Upload to release
- uses: softprops/action-gh-release@v2
+ uses: softprops/action-gh-release@v3
if: ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/') }}
with:
files: |
@@ -160,7 +160,7 @@ jobs:
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
- uses: actions/checkout@v6
+ uses: actions/checkout@v7
with:
fetch-depth: 0
@@ -181,11 +181,9 @@ jobs:
- name: Build with Nuitka
run: |
- python3 -c "import sys; sys.path.append('./app/supports'); import config; print(config.VERSION)" > version.txt
- version=$(sed -n '4p' version.txt)
- echo "VERSION=${version}" >> "$GITHUB_ENV"
- rm -rf version.txt
- python3 deploy.py
+ VERSION=$(python3 -c "from app.config.constants import VERSION; print(VERSION)")
+ echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
+ python3 scripts/deploy.py
chmod +x "dist/Ghost-Downloader-3.app/Contents/MacOS/Ghost-Downloader-3"
rm -rf "dist/Ghost-Downloader-3.build"
rm -rf "dist/Ghost-Downloader-3.dist"
@@ -230,14 +228,14 @@ jobs:
"$DMG_SOURCE_DIR"
- name: Upload to release
- uses: softprops/action-gh-release@v2
+ uses: softprops/action-gh-release@v3
if: ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/') }}
with:
files: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg
- name: Upload artifacts
if: ${{ github.event_name == 'workflow_dispatch' }}
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}
path: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg
@@ -258,7 +256,7 @@ jobs:
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
- uses: actions/checkout@v6
+ uses: actions/checkout@v7
with:
fetch-depth: 0
@@ -275,11 +273,9 @@ jobs:
- name: Build with Nuitka
run: |
- python3 -c "import sys; sys.path.append('./app/supports'); import config; print(config.VERSION)" > version.txt
- version=$(sed -n '4p' version.txt)
- echo "VERSION=${version}" >> "$GITHUB_ENV"
- rm -rf version.txt
- python deploy.py
+ VERSION=$(python3 -c "from app.config.constants import VERSION; print(VERSION)")
+ echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
+ python scripts/deploy.py
chmod +x "dist/Ghost-Downloader-3.dist/Ghost-Downloader-3.bin"
- name: Build .deb and .AppImage
@@ -371,7 +367,7 @@ jobs:
run: |
$distPath = "dist/Ghost-Downloader-3.dist"
$tarFile = "Ghost-Downloader-v${{ env.VERSION }}-Linux-${{ matrix.architecture }}.tar.xz"
-
+
# Create a tar.xz archive containing the contents of Ghost-Downloader.dist, without the folder itself
Write-Output "Creating tar.xz archive of $distPath..."
tar -cJf $tarFile -C $distPath .
@@ -379,7 +375,7 @@ jobs:
- name: Upload artifacts
if: ${{ github.event_name == 'workflow_dispatch' }}
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: Ghost-Downloader-v${{ env.VERSION }}-Linux-${{ matrix.architecture }}
path: |
@@ -388,7 +384,7 @@ jobs:
dist/Ghost-Downloader-v${{ env.VERSION }}-Linux-${{ matrix.architecture }}.AppImage
- name: Upload to release
- uses: softprops/action-gh-release@v2
+ uses: softprops/action-gh-release@v3
if: ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/') }}
with:
files: |
diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml
index c833916d..d0f61fe7 100644
--- a/.github/workflows/crowdin.yml
+++ b/.github/workflows/crowdin.yml
@@ -32,7 +32,7 @@ jobs:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
steps:
- name: Checkout
- uses: actions/checkout@v6
+ uses: actions/checkout@v7
with:
fetch-depth: 0
@@ -49,10 +49,10 @@ jobs:
- name: Install Qt translation tools
run: |
python -m pip install --upgrade pip
- pip install --timeout=300 "pyside6~=6.10.2"
+ pip install --timeout=300 "pyside6~=6.10.3"
- name: Refresh Qt translation assets
- run: python sync_i18n_res.py
+ run: python scripts/sync_i18n_res.py
- name: Upload sources and translations
if: github.event.inputs.operation == 'push'
@@ -81,7 +81,7 @@ jobs:
run: |
sudo chown -R "$(id -u):$(id -g)" .git app/assets
rm -f .git/COMMIT_EDITMSG
- python sync_i18n_res.py
+ python scripts/sync_i18n_res.py
- name: Update Crowdin contributors
if: github.event.inputs.operation == 'pull'
diff --git a/.gitmodules b/.gitmodules
index e69de29b..8913ec76 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "browser_extension/upstream"]
+ path = browser_extension/upstream
+ url = https://github.com/xifangczy/cat-catch.git
diff --git a/README.md b/README.md
index c0d17664..9814e4a8 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
<!-- PROJECT LOGO -->
<div align="center">
-![Banner](app/assets/banner.webp)
+![Banner](.github/assets/banner.webp)
<a href="https://trendshift.io/repositories/13847" target="_blank"><img src="https://trendshift.io/api/badge/repositories/13847" alt="XiaoYouChR%2FGhost-Downloader-3 | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
@@ -140,7 +140,7 @@ Thanks to all contributors who have participated in this project!
Distributed under the GPL v3.0 License. Open `LICENSE` for more details.
-Copyright © 2025 XiaoYouChR.
+Copyright © 2024-2026 XiaoYouChR.
<!-- CONTACT -->
## Contact
@@ -200,7 +200,6 @@ Copyright © 2025 XiaoYouChR.
[stars-url]: https://github.com/XiaoYouChR/Ghost-Downloader-3/stargazers
[issues-shield]: https://img.shields.io/github/issues/XiaoYouChR/Ghost-Downloader-3.svg?style=for-the-badge
[issues-url]: https://github.com/XiaoYouChR/Ghost-Downloader-3/issues
-[product-screenshot]: app/assets/screenshot.png
[release-shield]: https://img.shields.io/github/v/release/XiaoYouChR/Ghost-Downloader-3?style=for-the-badge
[release-url]: https://github.com/XiaoYouChR/Ghost-Downloader-3/releases/latest
[downloads-shield]: https://img.shields.io/github/downloads/XiaoYouChR/Ghost-Downloader-3/total?style=for-the-badge
diff --git a/README_zh.md b/README_zh.md
index b6880710..65c09145 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -8,7 +8,7 @@
<!-- PROJECT LOGO -->
<div align="center">
-![Banner](app/assets/banner.webp)
+![Banner](.github/assets/banner.webp)
<a href="https://trendshift.io/repositories/13847" target="_blank"><img src="https://trendshift.io/api/badge/repositories/13847" alt="XiaoYouChR%2FGhost-Downloader-3 | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
@@ -141,7 +141,7 @@
根据 GPL v3.0 许可证分发。打开 `LICENSE` 查看更多内容。
-Copyright © 2025 XiaoYouChR.
+Copyright © 2024-2026 XiaoYouChR.
<!-- CONTACT -->
## 联系
@@ -203,7 +203,6 @@ Copyright © 2025 XiaoYouChR.
[atomgit-stars-url]: https://gitcode.com/XiaoYouChR/Ghost-Downloader-3
[issues-shield]: https://img.shields.io/github/issues/XiaoYouChR/Ghost-Downloader-3.svg?style=for-the-badge
[issues-url]: https://github.com/XiaoYouChR/Ghost-Downloader-3/issues
-[product-screenshot]: app/assets/screenshot.png
[release-shield]: https://img.shields.io/github/v/release/XiaoYouChR/Ghost-Downloader-3?style=for-the-badge
[release-url]: https://github.com/XiaoYouChR/Ghost-Downloader-3/releases/latest
[downloads-shield]: https://img.shields.io/github/downloads/XiaoYouChR/Ghost-Downloader-3/total?style=for-the-badge
diff --git a/pyproject.toml b/pyproject.toml
deleted file mode 100644
index fbf40060..00000000
--- a/pyproject.toml
+++ /dev/null
@@ -1,27 +0,0 @@
-[project]
-name = "ghost-downloader-3"
-version = "3.8"
-description = "ghost-downloader-3"
-requires-python = ">=3.11"
-dependencies = [
- "desktop-notifier>=6.2.0",
- "libtorrent>=2.0.11",
- "libtorrent-windows-dll>=0.0.3; sys_platform == 'win32'",
- "loguru>=0.7.3",
- "niquests[http3,socks,speedups]>=3.18.2",
- "nuitka>=4.0.7",
- "pyside6~=6.10.2",
- "qrcode[png]>=8.2",
- "winloop>=0.6.0; sys_platform == 'win32'",
- "uvloop>=0.22.1; sys_platform != 'win32'",
- "pyobjc-framework-Cocoa>=10.0; sys_platform == 'darwin'",
- "aioftp[socks]>=0.27.2",
- "pyside6-fluent-widgets>=1.11.1",
- "m3u8>=6.0.0",
- "mpegdash>=0.4.1",
-]
-
-[dependency-groups]
-dev = [
- "types-libtorrent>=2.0.11.20250816",
-]
diff --git a/scripts/Ghost-Downloader-3.iss b/scripts/Ghost-Downloader-3.iss
new file mode 100644
index 00000000..d16de399
--- /dev/null
+++ b/scripts/Ghost-Downloader-3.iss
@@ -0,0 +1,71 @@
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define MyAppName "Ghost Downloader"
+#define MyAppVersion "APPLICATION_VERSION"
+#define MyAppPublisher "XiaoYouChR"
+#define MyAppURL "https://github.com/XiaoYouChR/Ghost-Downloader-3/"
+#define MyAppExeName "Ghost-Downloader-3.exe"
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{C7E5C3F5-8579-4C76-BC5F-2D18D82FD9B8}
+AppName={#MyAppName}
+AppVersion={#MyAppVersion}
+;AppVerName={#MyAppName} {#MyAppVersion}
+AppPublisher={#MyAppPublisher}
+AppPublisherURL={#MyAppURL}
+AppSupportURL={#MyAppURL}
+AppUpdatesURL={#MyAppURL}
+SourceDir=..
+DefaultDirName={autopf}\{#MyAppName}
+UninstallDisplayIcon={app}\{#MyAppExeName}
+; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run
+; on anything but x64 and Windows 11 on Arm.
+ArchitecturesAllowed=x64compatible
+; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the
+; install be done in "64-bit mode" on x64 or Windows 11 on Arm,
+; meaning it should use the native 64-bit Program Files directory and
+; the 64-bit view of the registry.
+ArchitecturesInstallIn64BitMode=x64compatible
+DisableProgramGroupPage=yes
+LicenseFile=LICENSE
+; Remove the following line to run in administrative install mode (install for all users).
+PrivilegesRequired=lowest
+OutputDir=dist
+OutputBaseFilename=Ghost-Downloader-v{#MyAppVersion}-Windows-Setup
+SetupIconFile=app/assets/installer_logo.ico
+SolidCompression=yes
+WizardStyle=modern
+
+[Languages]
+Name: "english"; MessagesFile: "compiler:Default.isl"
+Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
+Name: "chinesetraditional"; MessagesFile: "compiler:Languages\ChineseTraditional.isl"
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[Files]
+Source: "dist/Ghost-Downloader-3.dist/{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
+Source: "dist/Ghost-Downloader-3.dist/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+[Icons]
+Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
+Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
+
+[Registry]
+; Uninstall-time cleanup of the per-user assoc keys written at runtime; dontcreatekey writes nothing at install
+Root: HKCU; Subkey: "Software\Classes\GhostDownloader.torrent"; Flags: dontcreatekey uninsdeletekey
+Root: HKCU; Subkey: "Software\Classes\GhostDownloader.m3u8"; Flags: dontcreatekey uninsdeletekey
+Root: HKCU; Subkey: "Software\Classes\GhostDownloader.m3u"; Flags: dontcreatekey uninsdeletekey
+Root: HKCU; Subkey: "Software\Classes\GhostDownloader.mpd"; Flags: dontcreatekey uninsdeletekey
+Root: HKCU; Subkey: "Software\Classes\.torrent\OpenWithProgids"; ValueType: none; ValueName: "GhostDownloader.torrent"; Flags: dontcreatekey uninsdeletevalue
+Root: HKCU; Subkey: "Software\Classes\.m3u8\OpenWithProgids"; ValueType: none; ValueName: "GhostDownloader.m3u8"; Flags: dontcreatekey uninsdeletevalue
+Root: HKCU; Subkey: "Software\Classes\.m3u\OpenWithProgids"; ValueType: none; ValueName: "GhostDownloader.m3u"; Flags: dontcreatekey uninsdeletevalue
+Root: HKCU; Subkey: "Software\Classes\.mpd\OpenWithProgids"; ValueType: none; ValueName: "GhostDownloader.mpd"; Flags: dontcreatekey uninsdeletevalue
+
+[Run]
+Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
diff --git a/scripts/convert_to_pyqt6.py b/scripts/convert_to_pyqt6.py
new file mode 100644
index 00000000..2234eb17
--- /dev/null
+++ b/scripts/convert_to_pyqt6.py
@@ -0,0 +1,266 @@
+from __future__ import annotations
+
+import argparse
+import os
+import re
+import shutil
+import sys
+from pathlib import Path
+
+DEFAULT_BACKUP_DIR = ".convert_to_pyqt6_backup"
+
+DIRECTORY_EXCLUDES = {
+ ".git", ".hg", ".idea", ".mypy_cache", ".pytest_cache",
+ ".ruff_cache", ".venv", "__pycache__", "build", "dist", "node_modules",
+}
+
+
+def convertToPyQt(content: str, relativePath: Path) -> str:
+ qtcoreImportRe = re.compile(
+ r"^(\s*from\s+PyQt6\.QtCore\s+import\s+)(.+?)(\s*(?:#.*)?\r?\n?)$",
+ re.MULTILINE,
+ )
+ signalRe = re.compile(r"(?<!pyqt)\bSignal(?=\s*\()")
+ slotRe = re.compile(r"(?<!pyqt)\bSlot(?=\s*\()")
+ propertyRe = re.compile(r"(?<!pyqt)\bProperty(?=\s*\()")
+
+ def rewriteImport(match: re.Match[str]) -> str:
+ prefix, imports, suffix = match.groups()
+ imports = re.sub(r"(?<!pyqt)\bSignal\b", "pyqtSignal", imports)
+ imports = re.sub(r"(?<!pyqt)\bSlot\b", "pyqtSlot", imports)
+ imports = re.sub(r"(?<!pyqt)\bProperty\b", "pyqtProperty", imports)
+ return f"{prefix}{imports}{suffix}"
+
+ converted = content.replace("PySide6", "PyQt6")
+ converted = qtcoreImportRe.sub(rewriteImport, converted)
+ converted = signalRe.sub("pyqtSignal", converted)
+ converted = slotRe.sub("pyqtSlot", converted)
+ converted = propertyRe.sub("pyqtProperty", converted)
+ converted = converted.replace("plugin-enable=pyside6", "plugin-enable=pyqt6")
+
+ if relativePath.name == "sync_i18n_res.py":
+ syncFindToolRe = re.compile(
+ r"def findTool\(name: str\) -> str:\r?\n.*?(?=\r?\ndef findSources)",
+ re.DOTALL,
+ )
+ syncFindToolNew = (
+ "def findTool(*names: str) -> str:\n"
+ " for name in names:\n"
+ " executable = shutil.which(name)\n"
+ " if executable:\n"
+ " return executable\n"
+ "\n"
+ " suffix = \".exe\" if os.name == \"nt\" else \"\"\n"
+ " candidate = Path(sys.executable).resolve().with_name(f\"{name}{suffix}\")\n"
+ " if candidate.exists():\n"
+ " return str(candidate)\n"
+ "\n"
+ " raise FileNotFoundError(f\"Required tool was not found in PATH: {', '.join(names)}\")\n"
+ )
+ newline = "\r\n" if "\r\n" in converted else "\n"
+ converted = syncFindToolRe.sub(
+ syncFindToolNew.replace("\n", newline) + newline,
+ converted,
+ count=1,
+ )
+ converted = converted.replace(
+ 'findTool("pyside6-lupdate")',
+ 'findTool("pylupdate6", "lupdate", "pyside6-lupdate")',
+ )
+ converted = converted.replace(
+ 'findTool("pyside6-lrelease")',
+ 'findTool("lrelease", "pyside6-lrelease")',
+ )
+ converted = converted.replace(
+ 'findTool("pyside6-rcc")',
+ 'findTool("rcc", "pyside6-rcc")',
+ )
+
+ return converted
+
+
+def isExcluded(relativePath: Path) -> bool:
+ if any(part in DIRECTORY_EXCLUDES for part in relativePath.parts[:-1]):
+ return True
+ if relativePath.name in {"convert_to_pyqt5.py", Path(__file__).name, "uv.lock"}:
+ return True
+ if relativePath.parts and relativePath.parts[0] == DEFAULT_BACKUP_DIR:
+ return True
+ return False
+
+
+def findFiles(root: Path, includeMarkdown: bool) -> list[Path]:
+ textExtensions = {".md", ".py", ".toml", ".txt"}
+ files: list[Path] = []
+
+ for currentRoot, dirNames, fileNames in os.walk(root):
+ currentPath = Path(currentRoot)
+
+ dirNames[:] = [
+ name for name in dirNames
+ if name not in DIRECTORY_EXCLUDES
+ and name != DEFAULT_BACKUP_DIR
+ ]
+
+ for fileName in sorted(fileNames):
+ candidate = currentPath / fileName
+ relativePath = candidate.relative_to(root)
+
+ if isExcluded(relativePath):
+ continue
+
+ suffix = candidate.suffix.lower()
+ if suffix not in textExtensions:
+ continue
+ if suffix == ".md" and not includeMarkdown:
+ continue
+
+ files.append(candidate)
+
+ return files
+
+
+def copyTree(source: Path, output: Path) -> None:
+ for currentRoot, dirNames, fileNames in os.walk(source):
+ currentPath = Path(currentRoot)
+ relativeRoot = currentPath.relative_to(source)
+
+ dirNames[:] = [
+ name for name in dirNames
+ if name not in DIRECTORY_EXCLUDES
+ and name != DEFAULT_BACKUP_DIR
+ ]
+
+ destRoot = output / relativeRoot
+ destRoot.mkdir(parents=True, exist_ok=True)
+
+ for fileName in fileNames:
+ sourcePath = currentPath / fileName
+ relativePath = sourcePath.relative_to(source)
+ if isExcluded(relativePath):
+ continue
+ destPath = output / relativePath
+ destPath.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copy2(sourcePath, destPath)
+
+
+def parseArgs() -> argparse.Namespace:
+ parser = argparse.ArgumentParser(
+ description="Convert a PySide6 project to PyQt6 with minimal code changes.",
+ )
+ parser.add_argument(
+ "source_dir", nargs="?", default=".",
+ help="Project root to convert. Defaults to the current directory.",
+ )
+ parser.add_argument(
+ "-o", "--output-dir",
+ help="Write the converted project to this directory. Ignored with --in-place.",
+ )
+ parser.add_argument(
+ "--in-place", action="store_true",
+ help="Rewrite the project in place instead of writing a copy.",
+ )
+ parser.add_argument(
+ "--dry-run", action="store_true",
+ help="Report the files that would change without writing them.",
+ )
+ parser.add_argument(
+ "--backup-dir", default=DEFAULT_BACKUP_DIR,
+ help="Backup directory used with --in-place. Use an empty string to disable backups.",
+ )
+ parser.add_argument(
+ "--include-markdown", action="store_true",
+ help="Also rewrite Markdown documentation files.",
+ )
+ return parser.parse_args()
+
+
+def main() -> int:
+ args = parseArgs()
+ sourceDir = Path(args.source_dir).resolve()
+
+ if not sourceDir.is_dir():
+ raise SystemExit(f"Source directory does not exist: {sourceDir}")
+
+ if args.in_place and args.output_dir:
+ raise SystemExit("--output-dir cannot be used together with --in-place")
+
+ if args.in_place:
+ outputDir = None
+ elif args.output_dir:
+ outputDir = Path(args.output_dir).resolve()
+ else:
+ outputDir = sourceDir.parent / f"{sourceDir.name}_pyqt6"
+
+ if outputDir is not None and outputDir == sourceDir:
+ raise SystemExit("Output directory must be different from the source directory")
+
+ if outputDir is not None:
+ try:
+ outputDir.relative_to(sourceDir)
+ except ValueError:
+ pass
+ else:
+ raise SystemExit("Output directory must not be inside the source directory")
+
+ if outputDir is not None and not args.in_place and not args.dry_run:
+ copyTree(sourceDir, outputDir)
+
+ changedFiles = 0
+ inspectedFiles = 0
+ backupRoot = sourceDir / args.backup_dir
+
+ for filePath in findFiles(sourceDir, includeMarkdown=args.include_markdown):
+ relativePath = filePath.relative_to(sourceDir)
+ inspectedFiles += 1
+
+ try:
+ with filePath.open("r", encoding="utf-8", newline="") as f:
+ original = f.read()
+ except UnicodeDecodeError:
+ print(f"[skip] {relativePath} is not UTF-8 text")
+ continue
+
+ if relativePath.suffix.lower() == ".py":
+ converted = convertToPyQt(original, relativePath)
+ else:
+ converted = original.replace("pyside6-fluent-widgets", "pyqt6-fluent-widgets")
+ converted = converted.replace("pyside6", "pyqt6")
+ converted = converted.replace("PySide6", "PyQt6")
+
+ if converted == original:
+ continue
+
+ changedFiles += 1
+ dest = filePath if args.in_place else outputDir / relativePath
+ print(f"[change] {relativePath}")
+
+ if args.dry_run:
+ continue
+
+ if args.in_place and args.backup_dir:
+ backupPath = backupRoot / relativePath
+ if not backupPath.exists():
+ backupPath.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copy2(filePath, backupPath)
+
+ dest.parent.mkdir(parents=True, exist_ok=True)
+ with dest.open("w", encoding="utf-8", newline="") as f:
+ f.write(converted)
+
+ print(
+ f"Done. inspected={inspectedFiles}, changed={changedFiles}, "
+ f"mode={'in-place' if args.in_place else 'copy'}"
+ )
+
+ if args.in_place and changedFiles and not args.dry_run and args.backup_dir:
+ print(f"Backups saved to: {backupRoot}")
+
+ if outputDir is not None and not args.in_place:
+ print(f"Converted project saved to: {outputDir}")
+
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/scripts/deploy.py b/scripts/deploy.py
new file mode 100644
index 00000000..ac3d8763
--- /dev/null
+++ b/scripts/deploy.py
@@ -0,0 +1,246 @@
+import ast
+import os
+import plistlib
+import shutil
+import subprocess
+import sys
+from collections.abc import Iterable
+from pathlib import Path
+
+REPO = Path(__file__).resolve().parent.parent
+sys.path.insert(0, str(REPO))
+
+from app.config.constants import VERSION, YEAR, AUTHOR, DESKTOP_ID
+
+MACOS_DOCUMENT_TYPES = [
+ {"name": "种子文件", "extensions": ["torrent"], "icon": "torrent"},
+ {"name": "M3U8 播放列表", "extensions": ["m3u8", "m3u"], "icon": "m3u8"},
+ {"name": "DASH 清单", "extensions": ["mpd"], "icon": "m3u8"},
+]
+
+EXCLUDED_PACKS = {"jack_yao"}
+
+EXTRA_INCLUDE_PACKAGES = [
+ "urllib3",
+]
+PLATFORM_INCLUDE_PACKAGES = {
+ "win32": ["winrt"],
+}
+EXTRA_INCLUDE_MODULES = [
+ "app.view.dialogs.edit_task",
+]
+
+
+def findImports(files: Iterable[Path]) -> tuple[set[str], set[str]]:
+ appModules: set[str] = set()
+ thirdParty: set[str] = set()
+ for source in files:
+ tree = ast.parse(source.read_text(encoding="utf-8"), filename=str(source))
+ for node in ast.walk(tree):
+ if isinstance(node, ast.Import):
+ for alias in node.names:
+ dotted = alias.name
+ top = dotted.split(".")[0]
+ if top == "app":
+ base = Path(*dotted.split("."))
+ if base.with_suffix(".py").is_file() or (base / "__init__.py").is_file():
+ appModules.add(dotted)
+ elif top and top not in sys.stdlib_module_names:
+ thirdParty.add(top)
+ elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module:
+ module = node.module
+ top = module.split(".")[0]
+
+ if top == "app":
+ base = Path(*module.split("."))
+ if base.with_suffix(".py").is_file() or (base / "__init__.py").is_file():
+ appModules.add(module)
+ elif top and top not in sys.stdlib_module_names:
+ thirdParty.add(top)
+
+ for alias in node.names:
+ dotted = f"{module}.{alias.name}"
+ if top == "app":
+ base = Path(*dotted.split("."))
+ if base.with_suffix(".py").is_file() or (base / "__init__.py").is_file():
+ appModules.add(dotted)
+
+ return appModules, thirdParty
+
+
+def findIncludes() -> tuple[list[str], list[str]]:
+ featureFiles = (path for pack in findPacks() for path in pack.rglob("*.py"))
+ featureModules, featurePackages = findImports(featureFiles)
+ appModules, appPackages = findImports((REPO / "app").rglob("*.py"))
+
+ featuresDir = REPO / "features"
+ internalPackages = {featuresDir.name} | {item.name for item in featuresDir.iterdir() if item.is_dir()}
+
+ packages = (featurePackages - appPackages - internalPackages) | set(EXTRA_INCLUDE_PACKAGES)
+ packages |= set(PLATFORM_INCLUDE_PACKAGES.get(sys.platform, []))
+
+ modules = {
+ module
+ for module in featureModules - appModules
+ if not (Path(*module.split(".")) / "__init__.py").is_file()
+ } | set(EXTRA_INCLUDE_MODULES)
+
+ return sorted(packages), sorted(modules)
+
+
+def buildArgs() -> list[str]:
+ includePackages, includeModules = findIncludes()
+ includeArgs = [
+ *[f"--include-package={package}" for package in includePackages],
+ *[f"--include-module={module}" for module in includeModules],
+ ]
+
+ nuitka = f'"{sys.executable}" -m nuitka'
+
+ if sys.platform == "win32":
+ return [
+ nuitka,
+ '--standalone',
+ '--windows-console-mode=attach',
+ '--plugin-enable=pyside6',
+ *includeArgs,
+ '--assume-yes-for-downloads',
+ '--msvc=latest',
+ '--windows-icon-from-ico=app/assets/logo.ico',
+ '--include-data-dir=app/assets/file_icons=app/assets/file_icons',
+ '--company-name=XiaoYouChR',
+ '--product-name="Ghost Downloader"',
+ f'--file-version={VERSION}',
+ f'--product-version={VERSION}',
+ '--file-description="Ghost Downloader"',
+ f'--copyright="Copyright(C) {YEAR} {AUTHOR}"',
+ '--output-dir=dist',
+ 'ghost_downloader.py',
+ ]
+
+ if sys.platform == "darwin":
+ return [
+ nuitka,
+ '--standalone',
+ '--plugin-enable=pyside6',
+ *includeArgs,
+ '--static-libpython=no',
+ "--macos-create-app-bundle",
+ "--assume-yes-for-downloads",
+ "--macos-app-mode=gui",
+ f"--macos-app-version={VERSION}",
+ "--macos-app-icon=app/assets/logo.icns",
+ f'--copyright="Copyright(C) {YEAR} {AUTHOR}"',
+ '--output-dir=dist',
+ 'ghost_downloader.py',
+ ]
+
+ return [
+ nuitka,
+ '--standalone',
+ '--plugin-enable=pyside6',
+ *includeArgs,
+ '--include-qt-plugins=platforms',
+ '--include-module=PySide6.QtDBus',
+ '--assume-yes-for-downloads',
+ '--linux-icon=app/assets/logo.png',
+ '--output-dir=dist',
+ 'ghost_downloader.py',
+ ]
+
+
+def findPacks() -> list[Path]:
+ featuresDir = REPO / "features"
+ if not featuresDir.is_dir():
+ raise FileNotFoundError(f"features directory not found: {featuresDir}")
+
+ return sorted(
+ (
+ item
+ for item in featuresDir.iterdir()
+ if item.is_dir()
+ and item.name not in EXCLUDED_PACKS
+ and (item / "manifest.toml").is_file()
+ ),
+ key=lambda item: item.name,
+ )
+
+
+def copyPacks() -> None:
+ packs = findPacks()
+ if not packs:
+ raise RuntimeError("No feature packs were found to copy.")
+
+ if sys.platform == "darwin":
+ targetRoot = Path("dist") / "ghost_downloader.app" / "Contents" / "MacOS" / "features"
+ else:
+ targetRoot = Path("dist") / "ghost_downloader.dist" / "features"
+
+ if not targetRoot.parent.exists():
+ raise FileNotFoundError(f"dist directory does not exist: {targetRoot.parent}")
+
+ if targetRoot.exists():
+ shutil.rmtree(targetRoot)
+ targetRoot.mkdir(parents=True, exist_ok=True)
+
+ for source in packs:
+ shutil.copytree(source, targetRoot / source.name)
+
+ print(f"Copied feature packs to {targetRoot}: {[p.name for p in packs]}")
+
+
+def patchInfoPlist() -> None:
+ appBundle = Path("dist") / "ghost_downloader.app"
+ plistPath = appBundle / "Contents" / "Info.plist"
+ resourcesDir = appBundle / "Contents" / "Resources"
+ resourcesDir.mkdir(parents=True, exist_ok=True)
+
+ fileIconsDir = REPO / "app" / "assets" / "file_icons"
+ documentTypes = []
+ for entry in MACOS_DOCUMENT_TYPES:
+ shutil.copy(fileIconsDir / f"{entry['icon']}.icns", resourcesDir / f"{entry['icon']}.icns")
+ documentTypes.append(
+ {
+ "CFBundleTypeName": entry["name"],
+ "CFBundleTypeRole": "Viewer",
+ "CFBundleTypeExtensions": entry["extensions"],
+ "CFBundleTypeIconFile": f"{entry['icon']}.icns",
+ "LSHandlerRank": "Alternate",
+ }
+ )
+
+ with open(plistPath, "rb") as f:
+ plist = plistlib.load(f)
+ plist["CFBundleDocumentTypes"] = documentTypes
+ plist["CFBundleIdentifier"] = DESKTOP_ID
+ plist["CFBundleURLTypes"] = [{
+ "CFBundleURLName": DESKTOP_ID,
+ "CFBundleURLSchemes": ["ghostdownloader"],
+ }]
+ with open(plistPath, "wb") as f:
+ plistlib.dump(plist, f)
+
+ print(f"Patched Info.plist with {len(documentTypes)} document types + URL scheme")
+
+
+def main() -> int:
+ os.chdir(REPO)
+
+ args = buildArgs()
+ command = ' '.join(args)
+
+ print(command)
+ result = subprocess.run(command, shell=True)
+ if result.returncode != 0:
+ return result.returncode
+
+ copyPacks()
+
+ if sys.platform == "darwin":
+ patchInfoPlist()
+
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/scripts/sync_i18n_res.py b/scripts/sync_i18n_res.py
new file mode 100644
index 00000000..eaf61298
--- /dev/null
+++ b/scripts/sync_i18n_res.py
@@ -0,0 +1,88 @@
+import os
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+REPO = Path(__file__).resolve().parent.parent
+sys.path.insert(0, str(REPO))
+
+LANGUAGES = ["zh_CN", "en_US", "ja_JP", "zh_TW", "zh_HK", "ru_RU"]
+
+
+def findTool(name: str) -> str:
+ executable = shutil.which(name)
+ if executable:
+ return executable
+
+ suffix = ".exe" if os.name == "nt" else ""
+ candidate = Path(sys.executable).resolve().with_name(f"{name}{suffix}")
+ if candidate.exists():
+ return str(candidate)
+
+ raise FileNotFoundError(f"Required tool was not found in PATH: {name}")
+
+
+def findSources(root: str) -> list[str]:
+ sources: list[str] = []
+ baseDir = REPO / root
+
+ for dirPath, _, fileNames in os.walk(baseDir):
+ for fileName in fileNames:
+ if not fileName.endswith(".py"):
+ continue
+
+ fullPath = Path(dirPath, fileName).resolve()
+ relPath = fullPath.relative_to(REPO)
+
+ if relPath == Path("app/assets/resources.py"):
+ continue
+
+ sources.append(relPath.as_posix())
+
+ return sorted(sources)
+
+
+def main() -> int:
+ os.chdir(REPO)
+
+ sources = findSources("app")
+ sources.extend(findSources("features"))
+
+ i18nDir = REPO / "app" / "assets" / "i18n"
+ i18nDir.mkdir(parents=True, exist_ok=True)
+
+ lupdate = findTool("pyside6-lupdate")
+ for locale in LANGUAGES:
+ tsPath = i18nDir / f"gd3.{locale}.ts"
+ subprocess.run([
+ lupdate, "-no-ui-lines",
+ "-source-language", "zh_CN",
+ "-target-language", locale,
+ *sources,
+ "-ts", tsPath.as_posix(),
+ ], cwd=REPO, check=True)
+
+ lrelease = findTool("pyside6-lrelease")
+ for locale in LANGUAGES:
+ tsPath = i18nDir / f"gd3.{locale}.ts"
+ qmPath = i18nDir / f"gd3.{locale}.qm"
+ subprocess.run([
+ lrelease, tsPath.as_posix(),
+ "-qm", qmPath.as_posix(),
+ ], cwd=REPO, check=True)
+
+ rcc = findTool("pyside6-rcc")
+ resourcesQrc = REPO / "app" / "assets" / "resources.qrc"
+ resourcesPy = REPO / "app" / "assets" / "resources.py"
+ subprocess.run([
+ rcc, "-g", "python",
+ "-o", resourcesPy.as_posix(),
+ resourcesQrc.as_posix(),
+ ], cwd=REPO, check=True)
+
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())