mirror of
https://github.com/ikunshare/Onekey.git
synced 2026-01-13 00:27:32 +08:00
up: sync
This commit is contained in:
@@ -19,10 +19,10 @@ async def check_github_api_rate_limit(headers, session):
|
||||
remaining_requests = rate_limit['remaining']
|
||||
reset_time = rate_limit['reset']
|
||||
reset_time_formatted = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(reset_time))
|
||||
log.info(f' 🔄 剩余请求次数: {remaining_requests}')
|
||||
log.info(f'🔄 剩余请求次数: {remaining_requests}')
|
||||
else:
|
||||
log.error('Github请求数检查失败')
|
||||
return
|
||||
|
||||
if remaining_requests == 0:
|
||||
log.warning(f' ⚠ GitHub API 请求数已用尽,将在 {reset_time_formatted} 重置, 不想等生成一个填配置文件里')
|
||||
log.warning(f'⚠ GitHub API 请求数已用尽,将在 {reset_time_formatted} 重置, 不想等生成一个填配置文件里')
|
||||
@@ -25,7 +25,7 @@ async def gen_config_file():
|
||||
ensure_ascii=False,
|
||||
escape_forward_slashes=False))
|
||||
await f.close()
|
||||
log.info(' 🖱️ 程序可能为第一次启动,请填写配置文件后重新启动程序')
|
||||
log.info('🖱️ 程序可能为第一次启动,请填写配置文件后重新启动程序')
|
||||
|
||||
|
||||
async def load_config():
|
||||
|
||||
@@ -10,7 +10,7 @@ lock = asyncio.Lock()
|
||||
async def depotkey_merge(config_path, depots_config):
|
||||
if not config_path.exists():
|
||||
async with lock:
|
||||
log.error(' 👋 Steam默认配置不存在,可能是没有登录账号')
|
||||
log.error('👋 Steam默认配置不存在,可能是没有登录账号')
|
||||
return
|
||||
|
||||
async with aiofiles.open(config_path, encoding='utf-8') as f:
|
||||
|
||||
@@ -20,14 +20,14 @@ async def get_manifest(sha, path, steam_path: Path, repo, session):
|
||||
return collected_depots
|
||||
|
||||
content = await get(sha, path, repo, session)
|
||||
log.info(f' 🔄 清单下载成功: {path}')
|
||||
log.info(f'🔄 清单下载成功: {path}')
|
||||
|
||||
async with aiofiles.open(save_path, 'wb') as f:
|
||||
await f.write(content)
|
||||
|
||||
elif path == 'Key.vdf':
|
||||
content = await get(sha, path, repo, session)
|
||||
log.info(f' 🔄 密钥下载成功: {path}')
|
||||
log.info(f'🔄 密钥下载成功: {path}')
|
||||
depots_config = vdf.loads(content.decode('utf-8'))
|
||||
|
||||
for depot_id, depot_info in depots_config['depots'].items():
|
||||
|
||||
@@ -16,7 +16,7 @@ def get_steam_path():
|
||||
|
||||
return steam_path
|
||||
except Exception as e:
|
||||
log.error(f'Steam路径获取失败, {stack_error(e)}')
|
||||
log.error(f'❗ Steam路径获取失败, {stack_error(e)}')
|
||||
os.system('pause')
|
||||
return None
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
from colorama import Fore, Back, Style, init
|
||||
|
||||
init()
|
||||
|
||||
from .log import log
|
||||
|
||||
def init():
|
||||
print('\033[1;32;40m _____ __ _ _____ _ _ _____ __ __ ' + '\033[0m')
|
||||
print('\033[1;32;40m / _ \\ | \\ | | | ____| | | / / | ____| \\ \\ / /' + '\033[0m')
|
||||
print('\033[1;32;40m | | | | | \\| | | |__ | |/ / | |__ \\ \\/ /' + '\033[0m')
|
||||
print('\033[1;32;40m | | | | | |\\ | | __| | |\\ \\ | __| \\ / ' + '\033[0m')
|
||||
print('\033[1;32;40m | |_| | | | \\ | | |___ | | \\ \\ | |___ / /' + '\033[0m')
|
||||
print('\033[1;32;40m \\_____/ |_| \\_| |_____| |_| \\_\\ |_____| /_/' + '\033[0m')
|
||||
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}")
|
||||
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('本项目采用GNU General Public License v3开源许可证')
|
||||
log.info('版本:1.2.2')
|
||||
|
||||
@@ -43,7 +43,7 @@ async def main(app_id, repos):
|
||||
log.error(f' ⚠ 获取分支信息失败: {stack_error(e)}')
|
||||
|
||||
if selected_repo:
|
||||
log.info(f' 🔄 选择清单仓库:{selected_repo}')
|
||||
log.info(f'🔄 选择清单仓库:{selected_repo}')
|
||||
url = f'https://api.github.com/repos/{selected_repo}/branches/{app_id}'
|
||||
async with session.get(url, headers=headers, ssl=False) as r:
|
||||
r_json = await r.json()
|
||||
@@ -61,18 +61,18 @@ async def main(app_id, repos):
|
||||
if isSteamTools:
|
||||
migrate(st_use=True)
|
||||
await stool_add(collected_depots, app_id)
|
||||
log.info(' ✅ 找到SteamTools,已添加解锁文件')
|
||||
log.info('✅ 找到SteamTools,已添加解锁文件')
|
||||
if isGreenLuma:
|
||||
migrate(st_use=False)
|
||||
await greenluma_add([app_id])
|
||||
depot_config = {'depots': {depot_id: {'DecryptionKey': depot_key} for depot_id, depot_key in collected_depots}}
|
||||
await depotkey_merge(steam_path / 'config' / 'config.vdf', depot_config)
|
||||
if await greenluma_add([int(i) for i in depot_config['depots'] if i.isdecimal()]):
|
||||
log.info(' ✅ 找到GreenLuma,已添加解锁文件')
|
||||
log.info(f' ✅ 清单最后更新时间:{latest_date}')
|
||||
log.info(f' ✅ 入库成功: {app_id}')
|
||||
log.info('✅ 找到GreenLuma,已添加解锁文件')
|
||||
log.info(f'✅ 清单最后更新时间:{latest_date}')
|
||||
log.info(f'✅ 入库成功: {app_id}')
|
||||
os.system('pause')
|
||||
return True
|
||||
log.error(f' ⚠ 清单下载或生成失败: {app_id}')
|
||||
log.error(f'⚠ 清单下载或生成失败: {app_id}')
|
||||
os.system('pause')
|
||||
return False
|
||||
|
||||
@@ -17,22 +17,22 @@ async def get(sha, path, repo, session):
|
||||
if r.status == 200:
|
||||
total_size = int(r.headers.get('Content-Length', 0))
|
||||
if total_size == 0:
|
||||
log.error(f' 🔄 获取失败: {path} - 内容为空')
|
||||
log.error(f'🔄 获取失败: {path} - 内容为空')
|
||||
break
|
||||
chunk_size = 1024
|
||||
content = bytearray()
|
||||
|
||||
with tqdm_asyncio(total=total_size, unit='B', unit_scale=True, desc=f'🟢 下载 {path}', bar_format="{l_bar}{bar} [{n_fmt}/{total_fmt}] {postfix}") as pbar:
|
||||
with tqdm_asyncio(total=total_size, unit='B', unit_scale=True, desc=f'🔃 下载 {path}', bar_format="{l_bar}{bar} [{n_fmt}/{total_fmt}] {postfix}") 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}')
|
||||
log.error(f'🔄 获取失败: {path} - 状态码: {r.status}')
|
||||
except ClientError:
|
||||
log.error(f' 🔄 获取失败: {path} - 连接错误')
|
||||
log.error(f'🔄 获取失败: {path} - 连接错误')
|
||||
retry -= 1
|
||||
log.warning(f' 🔄 重试剩余次数: {retry} - {path}')
|
||||
log.error(f' 🔄 超过最大重试次数: {path}')
|
||||
raise Exception(f' 🔄 无法下载: {path}')
|
||||
log.warning(f'🔄 重试剩余次数: {retry} - {path}')
|
||||
log.error(f'🔄 超过最大重试次数: {path}')
|
||||
raise Exception(f'🔄 无法下载: {path}')
|
||||
|
||||
@@ -10,7 +10,7 @@ directory = Path(steam_path / "config" / "stplug-in")
|
||||
|
||||
def migrate(st_use):
|
||||
if st_use:
|
||||
log.info('检测到你正在使用SteamTools,尝试迁移旧文件')
|
||||
log.info('🔃 检测到你正在使用SteamTools,尝试迁移旧文件')
|
||||
if directory.exists():
|
||||
for filename in os.listdir(directory):
|
||||
if filename.startswith("Onekey_unlock_"):
|
||||
@@ -25,7 +25,7 @@ def migrate(st_use):
|
||||
except Exception as e:
|
||||
log.error(f'Failed to rename {filename} -> {new_filename}: {e}')
|
||||
else:
|
||||
log.error('故障,正在重新安装SteamTools')
|
||||
log.error('❗ 故障,正在重新安装SteamTools')
|
||||
temp_path = Path('./temp')
|
||||
temp_path.mkdir(exist_ok=True)
|
||||
down_url = 'https://steamtools.net/res/SteamtoolsSetup.exe'
|
||||
|
||||
@@ -13,7 +13,7 @@ async def stool_add(depot_data, app_id):
|
||||
lua_filepath = steam_path / "config" / "stplug-in" / lua_filename
|
||||
|
||||
async with lock:
|
||||
log.info(f' ✅ SteamTools解锁文件生成: {lua_filepath}')
|
||||
log.info(f'✅ SteamTools解锁文件生成: {lua_filepath}')
|
||||
async with aiofiles.open(lua_filepath, mode="w", encoding="utf-8") as lua_file:
|
||||
await lua_file.write(f'addappid({app_id}, 1, "None")\n')
|
||||
for depot_id, depot_key in depot_data:
|
||||
|
||||
Reference in New Issue
Block a user