The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
Fixed #105
XiaoYouChR0bfc1ef4a457
diff --git a/app/common/download_task.py b/app/common/download_task.pyindex 957e9df5..bd18b4e9 100644--- a/app/common/download_task.py+++ b/app/common/download_task.py@@ -209,15 +209,16 @@ class DownloadTask(QThread):async with worker.client.stream(url=self.url, headers=workingRangeHeaders, timeout=30,method="GET") as res:- async for chunk in res.aiter_bytes(chunk_size=65536): # aiter_content 的单位是字节, 即每64K写一次文件+ async for chunk in res.aiter_bytes():if worker.endPos <= worker.progress:breakif chunk:async with self.aioLock:await self.file.seek(worker.progress)await self.file.write(chunk)- worker.progress += 65536- cfg.globalSpeed += 64 # 我真的不想使用 len(chunk), 因为误差只有一点点+ _ = len(chunk)+ worker.progress += _+ cfg.globalSpeed += _if cfg.speedLimitation.value:if cfg.globalSpeed >= cfg.speedLimitation.value:await asyncio.sleep(1) # 在锁里面睡,只阻塞 worker, 不阻塞 supervisor@@ -247,13 +248,14 @@ class DownloadTask(QThread):WorkingRangeHeaders = self.headers.copy()async with worker.client.stream(url=self.url, headers=WorkingRangeHeaders, timeout=30,method="GET") as res:- async for chunk in res.aiter_bytes(chunk_size=65536): # aiter_content 的单位是字节, 即每64K写一次文件+ async for chunk in res.aiter_bytes(): # aiter_content 的单位是字节, 即每64K写一次文件if chunk:await self.file.seek(worker.progress)await self.file.write(chunk)- worker.progress += len(chunk)- cfg.globalSpeed += len(chunk) / 1024 # B 转 KB+ _ = len(chunk)+ worker.progress += _+ cfg.globalSpeed += _ # B 转 KBif cfg.speedLimitation.value:if cfg.globalSpeed >= cfg.speedLimitation.value:await asyncio.sleep(1) # 在锁里面睡,只阻塞 worker, 不阻塞 supervisordiff --git a/app/view/pop_up_window.py b/app/view/pop_up_window.pyindex a5cf569e..6a93577a 100644--- a/app/view/pop_up_window.py+++ b/app/view/pop_up_window.py@@ -123,6 +123,10 @@ class PopUpWindowBase(QWidget, Ui_PopUpWindow):def __moveIn(self):self.__playSound()++ if not hasattr(self, "geometryAnimation"):+ self.geometryAnimation = QPropertyAnimation(self, b"geometry")+# 动画self.geometryAnimation.setDuration(500)self.geometryAnimation.setStartValue(self.geometry())@@ -132,6 +136,9 @@ class PopUpWindowBase(QWidget, Ui_PopUpWindow):def __moveOut(self):+ if not hasattr(self, "geometryAnimation"):+ self.geometryAnimation = QPropertyAnimation(self, b"geometry")+self.geometryAnimation.setDuration(500)self.geometryAnimation.setStartValue(self.geometry())self.geometryAnimation.setEndValue(QRect(self.screenGeometry.width(), self.y(), self.width(), self.height()))diff --git a/app/view/setting_interface.py b/app/view/setting_interface.pyindex b3293caf..fd8352f8 100644--- a/app/view/setting_interface.py+++ b/app/view/setting_interface.py@@ -240,7 +240,8 @@ class SettingInterface(SmoothScrollArea):" KB/s",cfg.speedLimitation,self.downloadGroup,- 512+ 512,+ 1/1024)self.autoSpeedUpCard = SwitchSettingCard(