Skip to content

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

https://nuitka.net/posts/nuitka-this-week-1.html#coroutine-compatibility

XiaoYouChR05b6f1c7cf79
diff --git a/features/bili_pack/pack.py b/features/bili_pack/pack.py
index 7555ed16..c19561db 100644
--- a/features/bili_pack/pack.py
+++ b/features/bili_pack/pack.py
@@ -173,6 +173,8 @@ async def _getFileSizeWithClient(url: str, headers: dict, proxies: dict, client:
requestHeaders = headers.copy()
requestHeaders["range"] = "bytes=0-0"
+ # 兄弟这里有个血的教训, 在 nuitka 编译之后, 如果你 await response.close(), 那么 parse 代码就废了, 而且没有任何报错.
+
response = await client.get(
url,
headers=requestHeaders,
@@ -181,18 +183,15 @@ async def _getFileSizeWithClient(url: str, headers: dict, proxies: dict, client:
allow_redirects=True,
stream=True,
)
- try:
- response.raise_for_status()
- head = {k.lower(): v for k, v in response.headers.items()}
+ response.raise_for_status()
+ head = {k.lower(): v for k, v in response.headers.items()}
- if response.status_code == 206 and "content-range" in head:
- _left, _char, right = head["content-range"].rpartition("/")
- if right != "*":
- return int(right)
+ if response.status_code == 206 and "content-range" in head:
+ _left, _char, right = head["content-range"].rpartition("/")
+ if right != "*":
+ return int(right)
- raise ValueError("音视频流不支持范围请求,当前实现无法下载")
- finally:
- await response.close()
+ raise ValueError("音视频流不支持范围请求,当前实现无法下载")
async def parse(payload: dict) -> BilibiliTask: