diff --git a/common/init_text.py b/common/init_text.py index adbff5a..87ea1b8 100644 --- a/common/init_text.py +++ b/common/init_text.py @@ -9,7 +9,7 @@ def init(): print('\033[1;32;40m \\_____/ |_| \\_| |_____| |_| \\_\\ |_____| /_/' + '\033[0m') log.info('作者ikun0014') log.info('本项目基于wxy1343/ManifestAutoUpdate进行修改,采用GPL-3.0许可证') - log.info('版本:1.2.0') + log.info('版本:1.2.1') log.info('项目仓库:https://github.com/ikunshare/Onekey') log.info('官网:ikunshare.com') log.warning('本项目完全开源免费,如果你在淘宝,QQ群内通过购买方式获得,赶紧回去骂商家死全家\n交流群组:\nhttps://qm.qq.com/q/d7sWovfAGI\nhttps://t.me/ikunshare_group') \ No newline at end of file diff --git a/common/manifest_down.py b/common/manifest_down.py index 7db4f0d..1b098f7 100644 --- a/common/manifest_down.py +++ b/common/manifest_down.py @@ -1,6 +1,9 @@ from aiohttp import ClientError +from tqdm.asyncio import tqdm_asyncio + from .log import log + async def get(sha, path, repo, session): url_list = [ f'https://cdn.jsdmirror.com/gh/{repo}@{sha}/{path}', @@ -14,12 +17,21 @@ async def get(sha, path, repo, session): try: async with session.get(url, ssl=False) as r: if r.status == 200: - return await r.read() + total_size = int(r.headers.get('Content-Length', 0)) + chunk_size = 1024 + content = bytearray() + + with tqdm_asyncio(total=total_size, unit='B', unit_scale=True, desc=f'下载 {path}') as pbar: + async for chunk in r.content.iter_chunked(chunk_size): + content.extend(chunk) + pbar.update(len(chunk)) + + return content else: log.error(f' 🔄 获取失败: {path} - 状态码: {r.status}') except ClientError: log.error(f' 🔄 获取失败: {path} - 连接错误') retry -= 1 - log.warning(f' 🔄 重试剩余次数: {retry} - {path}') - log.error(f' 🔄 超过最大重试次数: {path}') - raise Exception(f' 🔄 无法下载: {path}') \ No newline at end of file + log.warning(f' 🔄 重试剩余次数: {retry} - {path}') + log.error(f' 🔄 超过最大重试次数: {path}') + raise Exception(f' 🔄 无法下载: {path}')