fix: 尝试修复下载速度过慢导致Timeout

This commit is contained in:
ikun
2024-09-27 13:20:49 +08:00
parent 1e5f0b6774
commit b8d76f98da
3 changed files with 25 additions and 28 deletions

View File

@@ -9,23 +9,26 @@ from .log import log
async def gen_config_file():
qa1 = "温馨提示Github_Personal_Token可在Github设置的最底下开发者选项找到详情看教程"
tutorial = "https://ikunshare.com/Onekey_tutorial"
default_config ={
"Github_Personal_Token": "",
"Custom_Steam_Path": "",
"QA1": qa1,
"教程": tutorial
}
async with aiofiles.open("./config.json",
mode="w",
encoding="utf-8") as f:
await f.write(json.dumps(default_config,
indent=2,
ensure_ascii=False,
escape_forward_slashes=False))
await f.close()
log.info(' 🖱️ 程序可能为第一次启动,请填写配置文件后重新启动程序')
try:
qa1 = "温馨提示Github_Personal_Token可在Github设置的最底下开发者选项找到详情看教程"
tutorial = "https://ikunshare.com/Onekey_tutorial"
default_config ={
"Github_Personal_Token": "",
"Custom_Steam_Path": "",
"QA1": qa1,
"教程": tutorial
}
async with aiofiles.open("./config.json",
mode="w",
encoding="utf-8") as f:
await f.write(json.dumps(default_config,
indent=2,
ensure_ascii=False,
escape_forward_slashes=False))
await f.close()
log.info('🖱️ 程序可能为第一次启动,请填写配置文件后重新启动程序')
except Exception as e:
log.error(f'❗ 配置文件生成失败,{stack_error(e)}')
async def load_config():

View File

@@ -11,9 +11,9 @@ def init():
print(f"{Fore.GREEN}{Back.BLACK}{Style.BRIGHT} | | | | | |\\ | | __| | |\\ \\ | __| \\ / {Style.RESET_ALL}")
print(f"{Fore.GREEN}{Back.BLACK}{Style.BRIGHT} | |_| | | | \\ | | |___ | | \\ \\ | |___ / /{Style.RESET_ALL}")
print(f"{Fore.GREEN}{Back.BLACK}{Style.BRIGHT} \\_____/ |_| \\_| |_____| |_| \\_\\ |_____| /_/{Style.RESET_ALL}")
log.info('作者ikun0014')
log.info('作者ikun0014')
log.info('本项目采用GNU General Public License v3开源许可证')
log.info('版本1.2.2')
log.info('版本1.2.3')
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')

View File

@@ -9,14 +9,8 @@ async def get(sha, path, repo, session):
f'https://cdn.jsdmirror.com/gh/{repo}@{sha}/{path}',
f'https://jsd.onmicrosoft.cn/gh/{repo}@{sha}/{path}',
f'https://raw.dgithub.xyz/{repo}/{sha}/{path}',
f'https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://raw.kkgithub.com/{repo}/{sha}/{path}',
f'https://gitdl.cn/https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://ghp.ci/https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://ghproxy.net/https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://fastly.jsdelivr.net/gh/{repo}@{sha}/{path}',
f'https://jsdelivr.pai233.top/gh/{repo}@{sha}/{path}',
f'https://cdn.jsdelivr.net/gh/{repo}@{sha}/{path}',
f'https://raw.gitmirror.com/{repo}/{sha}/{path}',
f'https://raw.githubusercontent.com/{repo}/{sha}/{path}'
]
retry = 3
while retry:
@@ -25,7 +19,7 @@ async def get(sha, path, repo, session):
async with session.get(url, ssl=False) as r:
if r.status == 200:
total_size = int(r.headers.get('Content-Length', 0))
chunk_size = 1024
chunk_size = 2048
content = bytearray()
with tqdm_asyncio(total=total_size, unit='B', unit_scale=True, desc=f'下载 {path}', colour='#ffadad') as pbar: