The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
feat: 新增任务窗口没有正确获取文件名的时候可以新建任务, 防止被硬控
XiaoYouChRe25fda2db3dd
diff --git a/app/common/config.py b/app/common/config.pyindex 4447b521..f537805a 100644--- a/app/common/config.py+++ b/app/common/config.py@@ -102,7 +102,7 @@ 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"}# 附件类型必须全部小写-attachmentTypes = """3gp 7z aac ace aif arj asf avi bin bz2 exe gz gzip img iso lzh m4a m4v mkv mov mp3 mp4 mpa mpe+attachmentTypes = """3gp 7z aac ace aif arj asf avi bin bz2 dmg exe gz gzip img iso lzh m4a m4v mkv mov mp3 mp4 mpa mpempeg mpg msi msu ogg ogv pdf plj pps ppt qt ra rar rm rmvb sea sit sitx tar tif tiffwav wma wmv z zip esd wim msp apk apks apkm cab msp"""diff --git a/app/components/add_task_dialog.py b/app/components/add_task_dialog.pyindex ac32af3c..52d97f79 100644--- a/app/components/add_task_dialog.py+++ b/app/components/add_task_dialog.py@@ -131,8 +131,9 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):for i in range(self.taskTableWidget.rowCount()):item = self.taskTableWidget.item(i, 0)+ fileName = item.text() if item.text() != item.data(1) else None- addDownloadTask(item.data(1), item.text(), str(path), self.customHeaders, preBlockNum=self.blockNumCard.configItem.value)+ addDownloadTask(item.data(1), fileName, str(path), self.customHeaders, preBlockNum=self.blockNumCard.configItem.value)self.close()@@ -151,8 +152,9 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):for i in range(self.taskTableWidget.rowCount()):item = self.taskTableWidget.item(i, 0)+ fileName = item.text() if item.text() != item.data(1) else None- addDownloadTask(item.data(1), item.text(), str(path), self.customHeaders, "waiting", self.blockNumCard.configItem.value)+ addDownloadTask(item.data(1), fileName, str(path), self.customHeaders, "paused", self.blockNumCard.configItem.value)self.close()@@ -177,8 +179,15 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):def __handleUrl(self, url: str, index: int):try:_url, fileName, fileSize = getLinkInfo(url, self.customHeaders)- self.__addTableRowSignal.emit(fileName, str(fileSize), url) # 不希望使用重定向后的url,故使用原始url-+ # 查找是否存在该 URL 的行+ for i in range(self.taskTableWidget.rowCount()):+ if self.taskTableWidget.item(i, 0).data(1) == url:+ # 更新文件名和文件大小+ self.taskTableWidget.item(i, 0).setText(fileName)+ self.taskTableWidget.item(i, 1).setText(getReadableSize(int(fileSize)))+ return+ # 如果不存在则添加新行+ self.__addTableRowSignal.emit(fileName, str(fileSize), url)except Exception as e:self.__gotWrong.emit(repr(e), index)@@ -239,6 +248,7 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):if url in addedUrls:_ = urlRe.search(url)if _:+ self.__addTableRow(url, "0", url) # 新增卡片并设置文件名和文件大小为“正在获取...”self.threads.append(Thread(target=self.__handleUrl, args=(url, index), daemon=True))else:InfoBar.warning(@@ -251,6 +261,8 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):parent=self.parent())+ self.yesButton.setEnabled(True)+if self.threads:for thread in self.threads:thread.start()@@ -260,6 +272,3 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):def __waitForThreads(self):for thread in self.threads:thread.join()-- if self.taskTableWidget.rowCount() >= 0:- self.yesButton.setEnabled(True)\ No newline at end of filediff --git a/app/components/custom_tray.py b/app/components/custom_tray.pyindex ba69003f..b78d2ab6 100644--- a/app/components/custom_tray.py+++ b/app/components/custom_tray.py@@ -67,7 +67,8 @@ class CustomSystemTrayIcon(QSystemTrayIcon):self.parent().taskInterface.allPauseTasks()def __onQuitActionTriggered(self):- self.parent().themeChangedListener.terminate()+ if self.parent().themeChangedListener:+ self.parent().themeChangedListener.terminate()for i in self.parent().taskInterface.cards: # 是为了不写入历史记录安全的退出if i.status == 'working':diff --git a/app/view/main_window.py b/app/view/main_window.pyindex 110d8ec6..97a43fd9 100644--- a/app/view/main_window.py+++ b/app/view/main_window.py@@ -69,6 +69,7 @@ class MainWindow(MSFluentWindow):# 自定义主题信号连接self.themeChangedListener = None+ self.__onCustomThemeModeChanged(cfg.customThemeMode.value)cfg.customThemeMode.valueChanged.connect(self.__onCustomThemeModeChanged)# 创建未完成的任务@@ -252,7 +253,7 @@ class MainWindow(MSFluentWindow):def __showAddTaskBox(self):text = self.urlsTextw = AddTaskOptionDialog(self)- w.linkTextEdit.setText(text)+ w.linkTextEdit.setPlainText(text)w.exec()def closeEvent(self, event):