Skip to content

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

修复不可续传链接判断错误问题

AlphaQian6661a270bc37
diff --git a/app/common/methods.py b/app/common/methods.py
index 70edc842..2e2ddfb0 100644
--- a/app/common/methods.py
+++ b/app/common/methods.py
@@ -191,7 +191,8 @@ def getLocalTimeFromGithubApiTime(gmtTimeStr:str):
def getLinkInfo(url: str, headers: dict, fileName: str = "", verify: bool = False, proxy: str = "", followRedirects: bool = True) -> tuple:
if not proxy:
proxy = getProxy()
-
+ headers = headers.copy()
+ headers["Range"] = "bytes=0-"#尝试发送范围请求
# 使用 stream 请求获取响应
with httpx.stream("GET", url, headers=headers, verify=verify, proxy=proxy, follow_redirects=followRedirects) as response:
response.raise_for_status() # 如果状态码不是 2xx,抛出异常
@@ -201,7 +202,7 @@ def getLinkInfo(url: str, headers: dict, fileName: str = "", verify: bool = Fals
url = str(response.url)
# 获取文件大小, 判断是否可以分块下载
- if "content-length" not in head:
+ if "content-length" not in head or response.status_code == 200: #状态码为206才是范围请求,200表示服务器拒绝了范围请求同时将发送整个文件
fileSize = 0
else:
fileSize = int(head["content-length"])