The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
Closes #349
XiaoYouChR7201ee2f35e4
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.pyindex dc13d72c..a03b7b66 100644--- a/Ghost-Downloader-3.py+++ b/Ghost-Downloader-3.py@@ -4,7 +4,7 @@ import tracebackfrom time import localtime, strftime, timefrom loguru import logger-from PySide6.QtCore import QStandardPaths+from app.supports.paths import APP_DATA_DIR# import orjson# sys.modules['json'] = orjson@@ -25,8 +25,7 @@ def exceptionHook(exceptionType, value, tb):if "__compiled__" not in globals():sys.__excepthook__(*exceptionInfo)-appLocalDataLocation = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)-logger.add(f"{appLocalDataLocation}/GhostDownloader/GhostDownloader.log", rotation="512 KB", enqueue=True)+logger.add(f"{APP_DATA_DIR}/GhostDownloader.log", rotation="512 KB", enqueue=True)sys.excepthook = exceptionHookfrom qfluentwidgets import qconfig, setTheme@@ -40,7 +39,7 @@ logger.info(strftime("%Y-%m-%d %H:%M:%S", localtime(time())),)-qconfig.load(f"{appLocalDataLocation}/GhostDownloader/UserConfig.json", cfg)+qconfig.load(f"{APP_DATA_DIR}/UserConfig.json", cfg)if cfg.get(cfg.dpiScale) != 0:os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"diff --git a/app/supports/paths.py b/app/supports/paths.pynew file mode 100644index 00000000..e4f1405b--- /dev/null+++ b/app/supports/paths.py@@ -0,0 +1,11 @@+import sys+from pathlib import Path++from PySide6.QtCore import QStandardPaths++_executableDir = Path(sys.argv[0]).resolve().parent+APP_DATA_DIR: str = (+ str(_executableDir / "GhostDownloader")+ if (_executableDir / "GhostDownloader").is_dir()+ else f"{QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)}/GhostDownloader"+)diff --git a/app/supports/recorder.py b/app/supports/recorder.pyindex 094545bd..9c05a06e 100644--- a/app/supports/recorder.py+++ b/app/supports/recorder.py@@ -1,17 +1,16 @@from pathlib import Pathimport orjson-from PySide6.QtCore import QStandardPathsfrom loguru import loggerfrom app.bases.models import Task+from app.supports.paths import APP_DATA_DIRclass TaskRecorder:def __init__(self):- appLocalDataLocation = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)- self.recordFile = Path(f"{appLocalDataLocation}/GhostDownloader/Memory.log")+ self.recordFile = Path(APP_DATA_DIR) / "Memory.log"if not self.recordFile.exists():self.recordFile.parent.mkdir(parents=True, exist_ok=True)self.recordFile.touch()diff --git a/app/supports/utils.py b/app/supports/utils.pyindex 26bbe650..d9d25efd 100644--- a/app/supports/utils.py+++ b/app/supports/utils.py@@ -9,12 +9,13 @@ from typing import TYPE_CHECKING, Callablefrom http.cookiejar import CookieJarfrom niquests.cookies import RequestsCookieJar, cookiejar_from_dictfrom urllib.request import getproxies-from PySide6.QtCore import QUrl, Qt, QProcess, QStandardPaths+from PySide6.QtCore import QUrl, Qt, QProcessfrom PySide6.QtGui import QDesktopServicesfrom loguru import loggerfrom qfluentwidgets import MessageBox, ToolButton, FluentIconfrom app.supports.config import cfg+from app.supports.paths import APP_DATA_DIRif TYPE_CHECKING:from app.bases.models import Task@@ -102,8 +103,7 @@ def openFolder(path):def openAppLogFolder():- appLocalDataLocation = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)- openFolder(f"{appLocalDataLocation}/GhostDownloader/GhostDownloader.log")+ openFolder(f"{APP_DATA_DIR}/GhostDownloader.log")def getProxies():diff --git a/features/ffmpeg_pack/config.py b/features/ffmpeg_pack/config.pyindex fbfc4bb7..a614a834 100644--- a/features/ffmpeg_pack/config.py+++ b/features/ffmpeg_pack/config.py@@ -4,7 +4,7 @@ import sysfrom pathlib import Pathfrom typing import TYPE_CHECKING-from PySide6.QtCore import QStandardPaths, Qt, Signal+from PySide6.QtCore import Qt, Signalfrom PySide6.QtWidgets import QFileDialogfrom qfluentwidgets import (ConfigItem,@@ -18,6 +18,7 @@ from qfluentwidgets import (from app.bases.models import PackConfigfrom app.services.core_service import coreServicefrom app.supports.config import cfg+from app.supports.paths import APP_DATA_DIRfrom app.supports.utils import toExecutable, toPosixPathif TYPE_CHECKING:@@ -106,7 +107,7 @@ class FFmpegInstallFolderCard(SettingCard):self._updatePath(folder)def _restoreDefault(self):- self._updatePath(f"{QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)}/GhostDownloader/FFmpeg")+ self._updatePath(f"{APP_DATA_DIR}/FFmpeg")class FFmpegRuntimeCard(SettingCard):@@ -169,7 +170,7 @@ class FFmpegRuntimeCard(SettingCard):class FFmpegConfig(PackConfig):- installFolder = ConfigItem("FFmpeg", "InstallFolder", f"{QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)}/GhostDownloader/FFmpeg", FolderValidator())+ installFolder = ConfigItem("FFmpeg", "InstallFolder", f"{APP_DATA_DIR}/FFmpeg", FolderValidator())def setupSettings(self, settingPage: "SettingPage"):self.ffmpegGroup = SettingCardGroup(self.tr("FFmpeg"), settingPage.container)diff --git a/features/m3u8_pack/config.py b/features/m3u8_pack/config.pyindex 1ecdb601..0cda560d 100644--- a/features/m3u8_pack/config.py+++ b/features/m3u8_pack/config.py@@ -4,7 +4,7 @@ import sysfrom pathlib import Pathfrom typing import TYPE_CHECKING-from PySide6.QtCore import QStandardPaths, Qt, Signal+from PySide6.QtCore import Qt, Signalfrom PySide6.QtWidgets import QFileDialogfrom qfluentwidgets import (BoolValidator,@@ -29,6 +29,7 @@ from qfluentwidgets import (from app.bases.models import PackConfigfrom app.services.core_service import coreServicefrom app.supports.config import cfg+from app.supports.paths import APP_DATA_DIRfrom app.supports.utils import toExecutable, toPosixPathfrom app.view.components.setting_cards import SpinBoxSettingCard@@ -114,7 +115,7 @@ class M3U8InstallFolderCard(SettingCard):self._updatePath(folder)def _restoreDefault(self):- defaultPath = f"{QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)}/GhostDownloader/M3U8DL"+ defaultPath = f"{APP_DATA_DIR}/M3U8DL"self._updatePath(defaultPath)@@ -181,7 +182,7 @@ class M3U8Config(PackConfig):installFolder = ConfigItem("M3U8","InstallFolder",- f"{QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)}/GhostDownloader/M3U8DL",+ f"{APP_DATA_DIR}/M3U8DL",FolderValidator(),)outputFormat = OptionsConfigItem("M3U8", "OutputFormat", "mp4", OptionsValidator(["mp4", "mkv"]))