feat:治疗傻逼的病

This commit is contained in:
ikun
2024-09-11 21:39:44 +08:00
parent 7352f20eb4
commit 4ced52a87f
8 changed files with 54 additions and 38 deletions

1
.gitignore vendored
View File

@@ -169,3 +169,4 @@ cython_debug/
*.xml
*.exe
*.dll
/main.dist

View File

@@ -1,13 +1,11 @@
import ujson as json
import aiofiles
from . import log, stack_error
from .stack_error import stack_error
from .log import log
import os
import sys
import asyncio
log = log.log
stack_error = stack_error.stack_error
# 生成配置文件
async def gen_config_file():
default_config ={

View File

@@ -11,7 +11,8 @@ async def depotkey_merge(config_path, depots_config):
log.error(' 👋 Steam默认配置不存在可能是没有登录账号')
return
async with aiofiles.open(config_path, encoding='utf-8') as f:
config = vdf.load(f)
content = await f.read()
config = vdf.loads(content)
software = config['InstallConfigStore']['Software']
valve = software.get('Valve') or software.get('valve')
steam = valve.get('Steam') or valve.get('steam')
@@ -19,5 +20,6 @@ async def depotkey_merge(config_path, depots_config):
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
new_content = vdf.dumps(config, pretty=True)
await f.write(new_content)
return True

View File

@@ -1,12 +1,10 @@
import winreg
import os
from common import log, config, stack_error
from .log import log
from .config import config
from .stack_error import stack_error
from pathlib import Path
stack_error = stack_error.stack_error
config = config.config
log = log.log
# 通过注册表获取Steam安装路径
def get_steam_path():
try:

View File

@@ -1,6 +1,4 @@
from common import getsteampath
steam_path = getsteampath.steam_path
from .getsteampath import steam_path
# 增加GreenLuma解锁相关文件
async def greenluma_add(depot_id_list):

View File

@@ -4,12 +4,10 @@ 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:

View File

@@ -1,26 +1,47 @@
import os
from common import log, getsteampath
import requests
import subprocess
from .log import log
from .getsteampath import steam_path
from pathlib import Path
# 设置文件目录
log = log.log
steam_path = getsteampath.steam_path
directory = Path(steam_path / "config" / "stplug-in")
# 遍历目录中的所有文件
def migrate():
for filename in os.listdir(directory):
if filename.startswith("Onekey_unlock_"):
new_filename = filename[len("Onekey_unlock_"):]
def migrate(st_use):
if st_use == True:
log.info('检测到你正在使用SteamTools尝试迁移旧文件')
if os.path.exists(directory):
for filename in os.listdir(directory):
if filename.startswith("Onekey_unlock_"):
new_filename = filename[len("Onekey_unlock_"):]
old_file = os.path.join(directory, filename)
new_file = os.path.join(directory, new_filename)
old_file = os.path.join(directory, filename)
new_file = os.path.join(directory, new_filename)
try:
# 使用 os.replace 进行强制替换
os.replace(old_file, new_file)
log.info(f'Renamed: {filename} -> {new_filename}')
except Exception as e:
log.error(f'Failed to rename {filename} -> {new_filename}: {e}')
else:
log.error('故障正在重新安装SteamTools')
temp_path = './temp'
if not os.path.exists(temp_path):
os.mkdir(temp_path)
down_url = 'https://steamtools.net/res/SteamtoolsSetup.exe'
out_path = './temp/SteamtoolsSetup.exe'
with requests.get(down_url, stream=True) as r:
if r.status_code == 200:
with open(out_path, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
else:
log.error('网络错误')
subprocess.run(str(out_path))
os.rmdir(temp_path)
else:
log.info('未使用SteamTools停止迁移')
try:
# 使用 os.replace 进行强制替换
os.replace(old_file, new_file)
log.info(f'Renamed: {filename} -> {new_filename}')
except Exception as e:
log.error(f'Failed to rename {filename} -> {new_filename}: {e}')
migrate = migrate

View File

@@ -14,7 +14,7 @@ config = config.config
lock = asyncio.Lock()
steam_path = getsteampath.steam_path
isGreenLuma = any((steam_path / dll).exists() for dll in ['GreenLuma_2024_x86.dll', 'GreenLuma_2024_x64.dll', 'User32.dll'])
isSteamTools = (steam_path / 'config' / 'stplug-in').is_dir()
isSteamTools = (steam_path / 'config' / 'stUI').is_dir()
stunlock = stunlock.stunlock
glunlock = glunlock.glunlock
stack_error = stack_error.stack_error
@@ -31,7 +31,7 @@ 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.8')
log.info('版本1.1.9')
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')
@@ -130,9 +130,11 @@ async def main(app_id):
collected_depots.extend(result)
if collected_depots:
if isSteamTools:
migration(st_use=True)
await stunlock(collected_depots, app_id)
log.info(' ✅ 找到SteamTools已添加解锁文件')
if isGreenLuma:
migration(st_use=False)
await glunlock([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)
@@ -147,14 +149,12 @@ async def main(app_id):
return False
repos = [
'ManifestHub/ManifestHub',
'ikun0014/ManifestHub',
'Auiowu/ManifestAutoUpdate',
'tymolu233/ManifestAutoUpdate'
]
if __name__ == '__main__':
try:
migration()
while True:
log.info('App ID可以在SteamDB或Steam商店链接页面查看')
app_id = input("请输入游戏AppID").strip()