The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
更新 Qt, Notifier, Niquests 依赖
XiaoYouChRd0ed5563c6e4
diff --git a/app/common/download_task.py b/app/common/download_task.pyindex 1c037944..8e4f4a08 100644--- a/app/common/download_task.py+++ b/app/common/download_task.py@@ -4,12 +4,12 @@ import sysimport timefrom abc import ABC, abstractmethodfrom asyncio import Task+from collections import dequefrom pathlib import Pathfrom threading import Threadfrom typing import List-from collections import deque-import httpx+import niquestsfrom PySide6.QtCore import QThread, Signalfrom loguru import logger@@ -21,7 +21,7 @@ from app.common.methods import getProxy, getReadableSize, getLinkInfo, createSpaclass DownloadWorker:"""Worker responsible for downloading a specific range of a file"""- def __init__(self, start, progress, end, client: httpx.AsyncClient):+ def __init__(self, start, progress, end, client: niquests.AsyncSession):self.startPos = startself.progress = progressself.endPos = end@@ -67,7 +67,7 @@ class DownloadWorker:class WorkerStrategy(ABC):"""Base strategy for handling download workers"""- def __init__(self, file, client: httpx.AsyncClient, url: str):+ def __init__(self, file, client: niquests.AsyncSession, url: str):self.file = fileself.client = clientself.url = url@@ -93,24 +93,23 @@ class ParallelDownloadStrategy(WorkerStrategy):workingRangeHeaders = self.client.headers.copy()workingRangeHeaders["range"] = f"bytes={worker.progress}-{worker.endPos - 1}"- async with self.client.stream(url=self.url, headers=workingRangeHeaders,- timeout=30, method="GET") as res:- res.raise_for_status()- if res.status_code != 206:- raise Exception(f"Server rejected range request, status code: {res.status_code}")+ res = await self.client.get(url=self.url, headers=workingRangeHeaders, timeout=30, stream=True)+ res.raise_for_status()+ if res.status_code != 206:+ raise Exception(f"Server rejected range request, status code: {res.status_code}")- async for chunk in res.aiter_bytes(chunk_size=65536):- if worker.isCompleted:- break+ async for chunk in await res.iter_raw(chunk_size=65536):+ if worker.isCompleted:+ break- if chunk:- self.file.seek(worker.progress)- self.file.write(chunk)- worker.progress += 65536- cfg.globalSpeed += 65536+ if chunk:+ self.file.seek(worker.progress)+ self.file.write(chunk)+ worker.progress += 65536+ cfg.globalSpeed += 65536- if cfg.speedLimitation.value and cfg.globalSpeed >= cfg.speedLimitation.value:- await asyncio.sleep(2)+ if cfg.speedLimitation.value and cfg.globalSpeed >= cfg.speedLimitation.value:+ await asyncio.sleep(1.5)worker.progress = worker.endPos@@ -124,7 +123,7 @@ class ParallelDownloadStrategy(WorkerStrategy):class SingleDownloadStrategy(WorkerStrategy):"""Strategy for non-parallel downloading"""- def __init__(self, file, client: httpx.AsyncClient, url: str, onComplete: callable = None):+ def __init__(self, file, client: niquests.AsyncSession, url: str, onComplete: callable = None):super().__init__(file, client, url)self.onComplete = onComplete@@ -138,20 +137,19 @@ class SingleDownloadStrategy(WorkerStrategy):while worker.progress <= worker.endPos:try:workingHeaders = self.client.headers.copy()- async with self.client.stream(url=self.url, headers=workingHeaders,- timeout=30, method="GET") as res:- res.raise_for_status()+ res = await self.client.get(url=self.url, headers=workingHeaders, timeout=30, stream=True)+ res.raise_for_status()- async for chunk in res.aiter_bytes():- if chunk:- self.file.seek(worker.progress)- self.file.write(chunk)- chunkSize = len(chunk)- worker.progress += chunkSize- cfg.globalSpeed += chunkSize+ async for chunk in await res.iter_raw():+ if chunk:+ self.file.seek(worker.progress)+ self.file.write(chunk)+ chunkSize = len(chunk)+ worker.progress += chunkSize+ cfg.globalSpeed += chunkSize- if cfg.speedLimitation.value and cfg.globalSpeed >= cfg.speedLimitation.value:- await asyncio.sleep(2)+ if cfg.speedLimitation.value and cfg.globalSpeed >= cfg.speedLimitation.value:+ await asyncio.sleep(1.5)if self.onComplete:self.onComplete()@@ -224,15 +222,13 @@ class DownloadTask(QThread):self.historyProgress = deque([self.progress] * 10) # Rolling window of 10 seconds for speed calculation# HTTP client setup- proxy = getProxy()- self.client = httpx.AsyncClient(- headers=headers,- verify=cfg.SSLVerify.value,- proxy=proxy,- limits=httpx.Limits(max_connections=256),- trust_env=False,- follow_redirects=True- )+ proxies = getProxy()+ self.client = niquests.AsyncSession()+ self.client.headers = headers+ self.client.verify = cfg.SSLVerify.value+ self.client.proxies = proxies+ self.client.trust_env = False+ self.client.allow_redirects = True# Initialize task in a separate threadself.initThread = Thread(target=self.__initTask, daemon=True)@@ -525,7 +521,7 @@ class DownloadTask(QThread):async def handleWorker(self, worker: DownloadWorker):await self.downloadStrategy.handleWorker(worker)if not self.autoSpeedUp or self.taskNum <= self.preBlockNum:# 如果开启了自动提速且添加了额外线程,则重新分配工作线程由自动提速控制- print("autoSpeedUp is off, reassigning worker")+ # print("autoSpeedUp is off, reassigning worker")self.__reassignWorker()self.doneTask += 1@@ -603,7 +599,7 @@ class DownloadTask(QThread):try:await self.supervisorTaskexcept asyncio.CancelledError:- await self.client.aclose()+ await self.client.close()# Clean up resourcesawait self.__cleanupResources()@@ -617,7 +613,7 @@ class DownloadTask(QThread):async def __cleanupResources(self):"""Clean up resources after download completes or is cancelled"""# Close HTTP client- await self.client.aclose()+ await self.client.close()# Close the download fileif self.file:diff --git a/app/common/methods.py b/app/common/methods.pyindex b8f9dbe0..1ca1809a 100644--- a/app/common/methods.py+++ b/app/common/methods.py@@ -10,12 +10,12 @@ from email.utils import decode_rfc2231from functools import wrapsfrom pathlib import Pathfrom time import sleep, localtime, time_ns+from typing import Optionalfrom urllib.parse import unquote, parse_qs, urlparse-import httpx+import niquestsfrom PySide6.QtCore import QUrl, QOperatingSystemVersion, QResourcefrom PySide6.QtGui import QDesktopServices-from PySide6.QtWidgets import QApplicationfrom loguru import loggerfrom qfluentwidgets import MessageBox@@ -25,23 +25,28 @@ from app.common.signal_bus import signalBusplugins = []+def isGreaterEqualWin10():""" determine if the Windows version ≥ Win10 """cv = QOperatingSystemVersion.current()return sys.platform == "win32" and cv.majorVersion() >= 10+def isLessThanWin10():""" determine if the Windows version < Win10"""cv = QOperatingSystemVersion.current()return sys.platform == "win32" and cv.majorVersion() < 10+def isGreaterEqualWin11():""" determine if the windows version ≥ Win11 """return isGreaterEqualWin10() and sys.getwindowsversion().build >= 22000+def isAbleToShowToast():return sys.platform == 'win32' and sys.getwindowsversion().build >= 16299 # 高于 Win10 1709+def loadPlugins(mainWindow, directory="{}/plugins".format(cfg.appPath)):try:for filename in os.listdir(directory):@@ -71,7 +76,7 @@ def loadPlugins(mainWindow, directory="{}/plugins".format(cfg.appPath)):logger.error(f"Error loading plugins: {e}")-def getSystemProxy():+def getSystemProxy() -> Optional[str]:if sys.platform == "win32":try:import winreg@@ -115,13 +120,19 @@ def getSystemProxy():return None-def getProxy():+def getProxy() -> Optional[dict]:if cfg.proxyServer.value == "Off":return Noneelif cfg.proxyServer.value == "Auto":- return getSystemProxy()+ return {+ "http": getSystemProxy(),+ "https": getSystemProxy(),+ }else:- return cfg.proxyServer.value+ return {+ "http": cfg.proxyServer.value,+ "https": cfg.proxyServer.value,+ }def getReadableSize(size):@@ -165,7 +176,7 @@ def retry(retries: int = 3, delay: float = 0.1, handleFunction: callable = None)breakelse:logger.warning(- f'Error: {repr(e)}! "{func.__name__}()"执行失败,将在{delay}秒后第[{i+1}/{retries}]次重试...'+ f'Error: {repr(e)}! "{func.__name__}()"执行失败,将在{delay}秒后第[{i + 1}/{retries}]次重试...')sleep(delay)@@ -183,7 +194,7 @@ def openFile(fileResolve):QDesktopServices.openUrl(QUrl.fromLocalFile(fileResolve))-def getLocalTimeFromGithubApiTime(gmtTimeStr:str):+def getLocalTimeFromGithubApiTime(gmtTimeStr: str):# 解析 GMT 时间gmtTime = datetime.fromisoformat(gmtTimeStr.replace("Z", "+00:00"))@@ -201,10 +212,12 @@ def getLocalTimeFromGithubApiTime(gmtTimeStr:str):return localTimeNaive-def attemptRegisterAppID(appId: str = "GD3", appName: str = "Ghost Downloader", iconPath: Path = Path("{}/logo.ico".format(cfg.appPath))):++def attemptRegisterAppID(appId: str = "GD3", appName: str = "Ghost Downloader",+ iconPath: Path = Path("{}/logo.ico".format(cfg.appPath))):import winregkeyPath = f"SOFTWARE\\Classes\\AppUserModelId\\{appId}"-+try:reg_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, keyPath)winreg.CloseKey(reg_key)@@ -212,7 +225,7 @@ def attemptRegisterAppID(appId: str = "GD3", appName: str = "Ghost Downloader",except FileNotFoundError:with open(iconPath, "wb") as f:f.write(QResource(":/image/logo.ico").data())-+winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, keyPath) as masterKey:winreg.SetValueEx(masterKey, "DisplayName", 0, winreg.REG_SZ, appName)@@ -221,13 +234,20 @@ def attemptRegisterAppID(appId: str = "GD3", appName: str = "Ghost Downloader",except Exception as e:logger.error(f"Could not register the application: {e}")-def getLinkInfo(url: str, headers: dict, fileName: str = "", verify: bool = cfg.SSLVerify.value, proxy: str = "", followRedirects: bool = True) -> tuple:- if not proxy:- proxy = getProxy()++def getLinkInfo(url: str, headers: dict, fileName: str = "", verify: bool = cfg.SSLVerify.value, proxies=None,+ followRedirects: bool = True) -> tuple:+ if proxies is not None:+ proxies = getProxy()+ else:+ proxies = {}+headers = headers.copy()- headers["Range"] = "bytes=0-"#尝试发送范围请求+ headers["Range"] = "bytes=0-" #尝试发送范围请求+# 使用 stream 请求获取响应, 反爬- with httpx.stream("GET", url, headers=headers, verify=verify, proxy=proxy, follow_redirects=followRedirects, trust_env=False) as response:+ with niquests.get(url, headers=headers, verify=verify, proxies=proxies, allow_redirects=followRedirects,+ stream=True) as response:response.raise_for_status() # 如果状态码不是 2xx,抛出异常head = response.headers@@ -242,11 +262,12 @@ def getLinkInfo(url: str, headers: dict, fileName: str = "", verify: bool = cfg.if right != "*":fileSize = int(right)- logger.info(f"content-range: {head['content-range']}, fileSize: {fileSize}, content-length: {head['content-length']}")+ logger.info(+ f"content-range: {head['content-range']}, fileSize: {fileSize}, content-length: {head['content-length']}")elif "content-length" in head:fileSize = int(head["content-length"])-+else:fileSize = 0logger.info("文件似乎支持续传,但无法获取文件大小")@@ -332,7 +353,8 @@ def bringWindowToTop(window):def addDownloadTask(url: str, fileName: str = None, filePath: str = None,- headers: dict = None, status:str = "working", preBlockNum: int= None, notCreateHistoryFile: bool = False, fileSize: int = -1):+ headers: dict = None, status: str = "working", preBlockNum: int = None,+ notCreateHistoryFile: bool = False, fileSize: int = -1):""" Global function to add download task """if not filePath:filePath = cfg.downloadFolder.value@@ -343,7 +365,9 @@ def addDownloadTask(url: str, fileName: str = None, filePath: str = None,if not headers:headers = Headers- signalBus.addTaskSignal.emit(url, fileName, filePath, headers, status, preBlockNum, notCreateHistoryFile, str(fileSize))+ signalBus.addTaskSignal.emit(url, fileName, filePath, headers, status, preBlockNum, notCreateHistoryFile,+ str(fileSize))+def showMessageBox(self, title: str, content: str, showYesButton=False, yesSlot=None):""" show message box """@@ -390,14 +414,14 @@ def isSparseSupported(filePath: Path) -> bool:# 调用 Windows API 获取卷信息success = ctypes.windll.kernel32.GetVolumeInformationW(- ctypes.c_wchar_p(rootPath), # 根路径- volumeNameBuffer, # 卷名缓冲区- ctypes.sizeof(volumeNameBuffer), # 缓冲区大小- None, # 序列号- None, # 最大组件长度- None, # 文件系统标志- fileSystemBuffer, # 文件系统名称缓冲区- ctypes.sizeof(fileSystemBuffer) # 缓冲区大小+ ctypes.c_wchar_p(rootPath), # 根路径+ volumeNameBuffer, # 卷名缓冲区+ ctypes.sizeof(volumeNameBuffer), # 缓冲区大小+ None, # 序列号+ None, # 最大组件长度+ None, # 文件系统标志+ fileSystemBuffer, # 文件系统名称缓冲区+ ctypes.sizeof(fileSystemBuffer) # 缓冲区大小)if not success:@@ -438,6 +462,7 @@ def isSparseSupported(filePath: Path) -> bool:logger.warning(f"文件系统检测失败: {repr(e)}")return False+def createSparseFile(filePath: Path) -> bool:"""创建一个支持稀疏写入的空文件。@@ -464,8 +489,8 @@ def createSparseFile(filePath: Path) -> bool:["fsutil", "sparse", "setflag", str(filePath)],capture_output=True,text=True,- check=True, # 如果命令返回非零退出码,则引发 CalledProcessError- creationflags=subprocess.CREATE_NO_WINDOW # 不显示控制台窗口+ check=True, # 如果命令返回非零退出码,则引发 CalledProcessError+ creationflags=subprocess.CREATE_NO_WINDOW # 不显示控制台窗口)# check=True 会处理错误,但为清晰起见保留检查if result.returncode != 0:@@ -493,4 +518,3 @@ def createSparseFile(filePath: Path) -> bool:except OSError as cleanup_error:logger.error(f"清理失败的文件 '{filePath}' 时出错: {cleanup_error}")return False-\ No newline at end of filediff --git a/app/components/Ui_TaskCard.py b/app/components/Ui_TaskCard.pyindex 92535452..042a99b7 100644--- a/app/components/Ui_TaskCard.py+++ b/app/components/Ui_TaskCard.py@@ -10,8 +10,8 @@from PySide6.QtCore import (QSize, Qt)from PySide6.QtWidgets import (QHBoxLayout, QSizePolicy, QVBoxLayout)-from qfluentwidgets import FluentIcon as FIF-from qfluentwidgets import (PixmapLabel, TitleLabel, ToolButton, PrimaryToolButton)+from qfluentwidgets import FluentIcon as FIF, SubtitleLabel+from qfluentwidgets import (PixmapLabel, ToolButton, PrimaryToolButton)from app.components.custom_components import IconBodyLabel@@ -21,70 +21,58 @@ class Ui_TaskCard(object):if not TaskCard.objectName():TaskCard.setObjectName(u"TaskCard")TaskCard.resize(793, 100)- TaskCard.setMinimumSize(QSize(793, 90))- TaskCard.setMaximumSize(QSize(16777215, 90))- self.cardHorizontalLayout = QHBoxLayout(TaskCard)- self.cardHorizontalLayout.setObjectName(u"cardHorizontalLayout")- self.cardHorizontalLayout.setContentsMargins(18, 8, 18, 8)- self.cardHorizontalLayout.setSpacing(18)+ TaskCard.setFixedHeight(68)++ self.vBoxLayout = QVBoxLayout(TaskCard)+ self.vBoxLayout.setSpacing(0)+ self.vBoxLayout.setContentsMargins(4, 0, 4, 0)++ self.horizontalLayout = QHBoxLayout(TaskCard)+ self.horizontalLayout.setObjectName(u"horizontalLayout")+ self.horizontalLayout.setContentsMargins(14, 0, 14, 0)+ self.horizontalLayout.setSpacing(8)self.LogoPixmapLabel = PixmapLabel(TaskCard)self.LogoPixmapLabel.setObjectName(u"LogoPixmapLabel")- self.LogoPixmapLabel.setMinimumSize(QSize(70, 70))- self.LogoPixmapLabel.setMaximumSize(QSize(70, 70))+ self.LogoPixmapLabel.setFixedSize(QSize(48, 48))self.LogoPixmapLabel.setScaledContents(True)- self.LogoPixmapLabel.setAlignment(Qt.AlignCenter)+ self.LogoPixmapLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)- self.cardHorizontalLayout.addWidget(self.LogoPixmapLabel)+ self.horizontalLayout.addWidget(self.LogoPixmapLabel)- self.verticalLayout = QVBoxLayout()+ self.verticalLayout = QVBoxLayout() # 放进度条的self.verticalLayout.setSpacing(0)self.verticalLayout.setObjectName(u"verticalLayout")- self.horizontalLayout = QHBoxLayout()- self.horizontalLayout.setObjectName(u"horizontalLayout")- self.horizontalLayout.setSpacing(6)-- # self.verticalLayout.addSpacing(15) # 把整体往下撑-self.verticalLayout_2 = QVBoxLayout()self.verticalLayout_2.setSpacing(0)self.verticalLayout_2.setObjectName(u"verticalLayout_2")- self.titleLabel = TitleLabel(TaskCard)+ self.titleLabel = SubtitleLabel(TaskCard)self.titleLabel.setObjectName(u"titleLabel")- sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)- sizePolicy.setHorizontalStretch(0)- sizePolicy.setVerticalStretch(0)- sizePolicy.setHeightForWidth(self.titleLabel.sizePolicy().hasHeightForWidth())+ sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)self.titleLabel.setSizePolicy(sizePolicy)self.titleLabel.setFixedHeight(38)self.verticalLayout_2.addWidget(self.titleLabel)- # 还需要把 statusHorizonLayout 在 horizonLayout 里面往下撑, 要不然非常难看!- self.verticalLayout_2.addSpacing(8)-self.statusHorizonLayout = QHBoxLayout()self.statusHorizonLayout.setObjectName(u"statusHorizonLayout")self.statusHorizonLayout.setSpacing(8)self.speedLabel = IconBodyLabel("下载速度", FIF.SPEED_HIGH, TaskCard)self.speedLabel.setObjectName(u"speedLabel")- self.speedLabel.setMinimumSize(QSize(0, 19))- self.speedLabel.setMaximumSize(QSize(16777215, 19))+ self.speedLabel.setFixedHeight(19)self.statusHorizonLayout.addWidget(self.speedLabel)self.leftTimeLabel = IconBodyLabel("剩余时间", FIF.STOP_WATCH, TaskCard)self.leftTimeLabel.setObjectName(u"leftTimeLabel")- self.leftTimeLabel.setMinimumSize(QSize(0, 19))- self.leftTimeLabel.setMaximumSize(QSize(16777215, 19))+ self.leftTimeLabel.setFixedHeight(19)self.statusHorizonLayout.addWidget(self.leftTimeLabel)self.progressLabel = IconBodyLabel("下载进度", FIF.LIBRARY, TaskCard)self.progressLabel.setObjectName(u"progressLabel")- self.progressLabel.setMinimumSize(QSize(0, 19))- self.progressLabel.setMaximumSize(QSize(16777215, 19))+ self.progressLabel.setFixedHeight(19)self.statusHorizonLayout.addWidget(self.progressLabel)self.statusHorizonLayout.addSpacing(1677215)@@ -97,8 +85,7 @@ class Ui_TaskCard(object):self.infoLabel = IconBodyLabel("若任务初始化过久,请检查网络连接后重试.", FIF.INFO, TaskCard)self.infoLabel.setObjectName(u"infoLabel")- self.infoLabel.setMinimumSize(QSize(0, 19))- self.infoLabel.setMaximumSize(QSize(16777215, 19))+ self.infoLabel.setFixedHeight(19)self.infoHorizonLayout.addWidget(self.infoLabel)@@ -108,28 +95,24 @@ class Ui_TaskCard(object):self.pauseButton = PrimaryToolButton(TaskCard)self.pauseButton.setObjectName(u"pauseButton")- self.pauseButton.setMinimumSize(QSize(31, 31))- self.pauseButton.setMaximumSize(QSize(31, 31))+ self.pauseButton.setFixedSize(QSize(31, 31))self.horizontalLayout.addWidget(self.pauseButton)self.folderButton = ToolButton(TaskCard)self.folderButton.setObjectName(u"folderButton")- self.folderButton.setMinimumSize(QSize(31, 31))- self.folderButton.setMaximumSize(QSize(31, 31))+ self.folderButton.setFixedSize(QSize(31, 31))self.horizontalLayout.addWidget(self.folderButton)self.cancelButton = ToolButton(TaskCard)self.cancelButton.setObjectName(u"cancelButton")- self.cancelButton.setMinimumSize(QSize(31, 31))- self.cancelButton.setMaximumSize(QSize(31, 31))+ self.cancelButton.setFixedSize(QSize(31, 31))self.horizontalLayout.addWidget(self.cancelButton)- self.verticalLayout.addLayout(self.horizontalLayout)-- self.cardHorizontalLayout.addLayout(self.verticalLayout)+ self.vBoxLayout.addLayout(self.horizontalLayout)+ self.vBoxLayout.addLayout(self.verticalLayout)# 初始化 Icon 类self.pauseButton.setIcon(FIF.PAUSE)diff --git a/app/components/custom_components.py b/app/components/custom_components.pyindex 2c10d16c..de14d20f 100644--- a/app/components/custom_components.py+++ b/app/components/custom_components.py@@ -41,7 +41,7 @@ class IconBodyLabel(BodyLabel):super().__init__(parent)self.setText(text)self.icon = icon- self.setContentsMargins(24, 0, 0, 0) # 给 Icon 和 Text 之间留出 4px 的间距+ self.setContentsMargins(20, 0, 0, 2) # 给 Icon 和 Text 之间留出 4px 的间距self.iconSize = QSize(16, 16)def paintEvent(self, event):@@ -53,7 +53,7 @@ class IconBodyLabel(BodyLabel):# 绘制图标iconHeight, iconWidth = self.iconSize.height(), self.iconSize.width()- iconRect = QRect(4, (self.height() - iconHeight) // 2, iconWidth, iconHeight)+ iconRect = QRect(0, (self.height() - iconHeight) // 2, iconWidth, iconHeight)drawIcon(self.icon, painter, iconRect)diff --git a/app/components/task_card.py b/app/components/task_card.pyindex 22c9795f..903f7688 100644--- a/app/components/task_card.py+++ b/app/components/task_card.py@@ -67,7 +67,7 @@ class TaskCard(CardWidget, Ui_TaskCard):self.titleLabel.setText(self.tr("正在初始化任务..."))self.LogoPixmapLabel.setPixmap(QPixmap(":/image/logo.png"))- self.LogoPixmapLabel.setFixedSize(70, 70)+ self.LogoPixmapLabel.setFixedSize(48, 48)self.progressBar = ProgressBar(self)self.progressBar.setObjectName(u"progressBar")@@ -78,7 +78,8 @@ class TaskCard(CardWidget, Ui_TaskCard):elif self.status == "finished":# TODO 超分辨率触发条件- _ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(128, 128) # 自动获取图标+ _ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(48, 48).scaled(128, 128, aspectMode=Qt.AspectRatioMode.KeepAspectRatio,+ mode=Qt.TransformationMode.SmoothTransformation) # 自动获取图标if _:pixmap = _@@ -87,7 +88,7 @@ class TaskCard(CardWidget, Ui_TaskCard):self.titleLabel.setText(self.fileName)self.LogoPixmapLabel.setPixmap(pixmap)- self.LogoPixmapLabel.setFixedSize(70, 70)+ self.LogoPixmapLabel.setFixedSize(48, 48)self.__onTaskFinished()@@ -193,10 +194,9 @@ class TaskCard(CardWidget, Ui_TaskCard):self.fileSize = self.task.fileSizeself.ableToParallelDownload = ableToParallelDownload- # TODO 因为Windows会返回已经处理过的只有左上角一点点的图像,所以需要超分辨率触发条件- # _ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(48, 48).scaled(70, 70, aspectMode=Qt.AspectRatioMode.KeepAspectRatio,- # mode=Qt.TransformationMode.SmoothTransformation) # 自动获取图标- _ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(128, 128) # 自动获取图标+ _ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(48, 48).scaled(128, 128, aspectMode=Qt.AspectRatioMode.KeepAspectRatio,+ mode=Qt.TransformationMode.SmoothTransformation) # 自动获取图标+ # _ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(128, 128) # 自动获取图标if _:pixmap = _@@ -206,7 +206,7 @@ class TaskCard(CardWidget, Ui_TaskCard):# 显示信息self.titleLabel.setText(self.fileName)self.LogoPixmapLabel.setPixmap(pixmap)- self.LogoPixmapLabel.setFixedSize(70, 70)+ self.LogoPixmapLabel.setFixedSize(48, 48)if self.status == "waiting":self.__showInfo(self.tr("排队中..."))@@ -469,8 +469,8 @@ class TaskCard(CardWidget, Ui_TaskCard):self.updateTaskRecord("finished")# 再获取一次图标- fileinfo = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(128,- 128) # 自动获取图标+ fileinfo = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(48, 48).scaled(128, 128, aspectMode=Qt.AspectRatioMode.KeepAspectRatio,+ mode=Qt.TransformationMode.SmoothTransformation) # 自动获取图标if fileinfo:pass@@ -478,7 +478,7 @@ class TaskCard(CardWidget, Ui_TaskCard):fileinfo = QPixmap(":/image/logo.png")self.LogoPixmapLabel.setPixmap(fileinfo)- self.LogoPixmapLabel.setFixedSize(70, 70)+ self.LogoPixmapLabel.setFixedSize(48, 48)self.status = "finished"diff --git a/app/components/update_dialog.py b/app/components/update_dialog.pyindex 2f27c2d4..51083a9d 100644--- a/app/components/update_dialog.py+++ b/app/components/update_dialog.py@@ -1,4 +1,4 @@-import httpx+import niquestsfrom PySide6.QtCore import QThread, Signal, QVersionNumberfrom PySide6.QtGui import QColorfrom PySide6.QtWidgets import QTableWidgetItem@@ -19,9 +19,9 @@ class GetUpdateThread(QThread):def run(self):try:_ = getProxy()- content = httpx.get(url="https://api.github.com/repos/XiaoYouChR/Ghost-Downloader-3/releases/latest", headers={+ content = niquests.get(url="https://api.github.com/repos/XiaoYouChR/Ghost-Downloader-3/releases/latest", headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.64"},- proxy=_, follow_redirects=True, trust_env=False).json()+ proxies=_, allow_redirects=True).json()tagName = content["tag_name"][1:]diff --git a/plugins/jy_os_page.py.DISABLE b/plugins/jy_os_page.py.DISABLEindex c17c1311..72bbce4c 100644--- a/plugins/jy_os_page.py.DISABLE+++ b/plugins/jy_os_page.py.DISABLE@@ -48,7 +48,7 @@ class getInfoThread(QThread):url="https://seelevollerei-my.sharepoint.com/personal/jackyao_xn--7et36u_cn/_layouts/52/download.aspx?share=Ecm5kLYVJedKlw60gcDkxPEB1PlS5Y-P-ttDSit_V8KuLw",headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.64"},- proxy=_, follow_redirects=True, trust_env=False).text)["OS"])+ proxy=_, allow_redirects=True, trust_env=False).text)["OS"])class HomeInterface(SmoothScrollArea):diff --git a/requirements.txt b/requirements.txtindex 1a6cd651..a5c97c34 100644--- a/requirements.txt+++ b/requirements.txt@@ -1,8 +1,8 @@PySide6-Fluent-Widgets>=1.8.0PysideSix-Frameless-Window>=0.7.1-PySide6==6.9.1+PySide6==6.8.3loguru-httpx[socks]+niquests[socks]nuitka==2.7.11-win11toast; sys_platform=="win32"+desktop-notifierdarkdetect[macos-listener]; sys_platform=="darwin"