Skip to content

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

fix: 修复代理获取异常的问题

XiaoYouChR0a7b4fe2806b
diff --git a/app/common/download_task.py b/app/common/download_task.py
index 1eef60e8..c2059d2d 100644
--- a/app/common/download_task.py
+++ b/app/common/download_task.py
@@ -55,8 +55,10 @@ class DownloadTask(QThread):
self.tasks: list[Task] = []
self.historySpeed = [0] * 10 # 历史速度 10 秒内的平均速度
+ _ = getProxy()
+
self.client = httpx.AsyncClient(headers=headers, verify=cfg.SSLVerify.value,
- proxy=getProxy(), limits=httpx.Limits(max_connections=256))
+ proxy=_, limits=httpx.Limits(max_connections=256), trust_env=False)
self.__initThread = Thread(target=self.__initTask, daemon=True) # TODO 获取文件名和文件大小的线程等信息, 暂时使用线程方式
self.__initThread.start()
@@ -214,7 +216,7 @@ class DownloadTask(QThread):
async with worker.client.stream(url=self.url, headers=workingRangeHeaders, timeout=30,
method="GET") as res:
if res.status_code != 206:
- raise httpx.HTTPStatusError(f"服务器拒绝了范围请求,状态码:{res.status_code}")
+ raise Exception(f"服务器拒绝了范围请求,状态码:{res.status_code}")
async for chunk in res.aiter_bytes():
if worker.endPos <= worker.progress:
break
diff --git a/app/common/methods.py b/app/common/methods.py
index e68fd2d7..bf7a4f6e 100644
--- a/app/common/methods.py
+++ b/app/common/methods.py
@@ -98,10 +98,11 @@ def getSystemProxy():
return f"http://{_.get('HTTPProxy')}:{_.get('HTTPPort')}"
else:
return None
+ return None
def getProxy():
- # print(cfg.proxyServer.value)
+ print(cfg.proxyServer.value)
if cfg.proxyServer.value == "Off":
return None
elif cfg.proxyServer.value == "Auto":
diff --git a/app/components/update_dialog.py b/app/components/update_dialog.py
index b8b663b0..91751146 100644
--- a/app/components/update_dialog.py
+++ b/app/components/update_dialog.py
@@ -18,9 +18,10 @@ class GetUpdateThread(QThread):
def run(self):
try:
+ _ = getProxy()
content = httpx.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=getProxy(), follow_redirects=True).json()
+ proxy=_, follow_redirects=True, trust_env=False).json()
tagName = content["tag_name"][1:]
diff --git a/plugins/jy_os_page.py b/plugins/jy_os_page.py
index e669965d..b2b62bc8 100644
--- a/plugins/jy_os_page.py
+++ b/plugins/jy_os_page.py
@@ -43,12 +43,12 @@ class getInfoThread(QThread):
# with open("./Content.json", "r", encoding="utf-8") as f:
# self.json = json.loads(f.read())["OS"]
# f.close()
-
+ _ = getProxy()
self.gotInfo.emit(json.loads(httpx.get(
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=getProxy(), follow_redirects=True).text)["OS"])
+ proxy=_, follow_redirects=True, trust_env=False).text)["OS"])
class HomeInterface(SmoothScrollArea):