fix:兼容问题

This commit is contained in:
ikun
2024-09-05 20:54:34 +08:00
parent b4ea1edb53
commit a7ce46aa52
4 changed files with 58 additions and 48 deletions

23
common/dkey_merge.py Normal file
View File

@@ -0,0 +1,23 @@
import asyncio
import aiofiles
import vdf
from .log import log
lock = asyncio.Lock()
async def depotkey_merge(config_path, depots_config):
if not config_path.exists():
async with lock:
log.error(' 👋 Steam默认配置不存在可能是没有登录账号')
return
async with aiofiles.open(config_path, encoding='utf-8') as f:
config = vdf.load(f)
software = config['InstallConfigStore']['Software']
valve = software.get('Valve') or software.get('valve')
steam = valve.get('Steam') or valve.get('steam')
if 'depots' not in steam:
steam['depots'] = {}
steam['depots'].update(depots_config['depots'])
async with aiofiles.open(config_path, mode='w', encoding='utf-8') as f:
vdf.dump(config, f, pretty=True)
return True

28
common/manifestdown.py Normal file
View File

@@ -0,0 +1,28 @@
from aiohttp import ClientError
from .log import log
# 下载清单
async def get(sha, path, repo, session):
url_list = [
# f'https://gh.api.99988866.xyz/https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://cdn.jsdmirror.com/gh/{repo}@{sha}/{path}',
f'https://jsd.onmicrosoft.cn/gh/{repo}@{sha}/{path}',
f'https://mirror.ghproxy.com/https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://gh.jiasu.in/https://raw.githubusercontent.com/{repo}/{sha}/{path}'
]
retry = 3
while retry:
for url in url_list:
try:
async with session.get(url, ssl=False) as r:
if r.status == 200:
return await r.read()
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}')

View File

@@ -11,7 +11,7 @@ steam_path = getsteampath.steam_path
# 增加SteamTools解锁相关文件
async def stool_add(depot_data, app_id):
lua_filename = f"Onekey_unlock_{app_id}.lua"
lua_filename = f"Onekey{app_id}.lua"
lua_filepath = steam_path / "config" / "stplug-in" / lua_filename
async with lock:

53
main.py
View File

@@ -4,8 +4,8 @@ import aiofiles
import traceback
import time
import asyncio
from common import log, config, getsteampath, stunlock, glunlock, stack_error
from aiohttp import ClientSession, ClientError
from common import log, config, getsteampath, stunlock, glunlock, stack_error, manifestdown, dkey_merge
from aiohttp import ClientSession
from pathlib import Path
log = log.log
@@ -17,6 +17,9 @@ isSteamTools = (steam_path / 'config' / 'stplug-in').is_dir()
stunlock = stunlock.stunlock
glunlock = glunlock.glunlock
stack_error = stack_error.stack_error
get = manifestdown.get
depotkey_merge = dkey_merge.depotkey_merge
print('\033[1;32;40m _____ __ _ _____ _ _ _____ __ __ ' + '\033[0m')
print('\033[1;32;40m / _ \\ | \\ | | | ____| | | / / | ____| \\ \\ / /' + '\033[0m')
@@ -26,37 +29,11 @@ print('\033[1;32;40m | |_| | | | \\ | | |___ | | \\ \\ | |___ / /' + '\033
print('\033[1;32;40m \\_____/ |_| \\_| |_____| |_| \\_\\ |_____| /_/' + '\033[0m')
log.info('作者ikun0014')
log.info('本项目基于wxy1343/ManifestAutoUpdate进行修改采用ACSL许可证')
log.info('版本1.1.6')
log.info('版本1.1.7')
log.info('项目仓库https://github.com/ikunshare/Onekey')
log.info('官网ikunshare.com')
log.warning('本项目完全开源免费如果你在淘宝QQ群内通过购买方式获得赶紧回去骂商家死全家\n交流群组:\n点击链接加入群聊【𝗶𝗸𝘂𝗻分享】https://qm.qq.com/q/d7sWovfAGI\nhttps://t.me/ikunshare_group')
# 下载清单
async def get(sha, path, repo, session):
url_list = [
# f'https://gh.api.99988866.xyz/https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://cdn.jsdmirror.com/gh/{repo}@{sha}/{path}',
f'https://jsd.onmicrosoft.cn/gh/{repo}@{sha}/{path}',
f'https://mirror.ghproxy.com/https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://raw.githubusercontent.com/{repo}/{sha}/{path}',
f'https://gh.jiasu.in/https://raw.githubusercontent.com/{repo}/{sha}/{path}'
]
retry = 3
while retry:
for url in url_list:
try:
async with session.get(url, ssl=False) as r:
if r.status == 200:
return await r.read()
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}')
# 获取清单信息
async def get_manifest(sha, path, steam_path: Path, repo, session):
collected_depots = []
@@ -85,24 +62,6 @@ async def get_manifest(sha, path, steam_path: Path, repo, session):
raise
return collected_depots
# 合并DecryptionKey
async def depotkey_merge(config_path, depots_config):
if not config_path.exists():
async with lock:
log.error(' 👋 Steam默认配置不存在可能是没有登录账号')
return
async with aiofiles.open(config_path, encoding='utf-8') as f:
config = vdf.load(f)
software = config['InstallConfigStore']['Software']
valve = software.get('Valve') or software.get('valve')
steam = valve.get('Steam') or valve.get('steam')
if 'depots' not in steam:
steam['depots'] = {}
steam['depots'].update(depots_config['depots'])
async with aiofiles.open(config_path, mode='w', encoding='utf-8') as f:
vdf.dump(config, f, pretty=True)
return True
async def check_github_api_rate_limit(headers, session):
url = 'https://api.github.com/rate_limit'