Files
Onekey/common/dkey_merge.py
2024-09-11 21:39:44 +08:00

26 lines
892 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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:
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')
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:
new_content = vdf.dumps(config, pretty=True)
await f.write(new_content)
return True