Compare commits

..

10 Commits

Author SHA1 Message Date
ikun0014
a475dcb6b8 1.4.6 2025-03-20 22:55:17 +08:00
ikun0014
2ea7c76004 1.4.6 2025-03-20 22:55:11 +08:00
ikun0014
14684cf1b7 fix: ManifestDownload 2025-03-20 22:54:43 +08:00
ikun0014
f560dab35f 1.4.5 2025-03-11 18:05:34 +08:00
ikun0014
8cdd9aa208 fix: SteamTools Import 2025-03-11 18:05:14 +08:00
ikun0014
37f862ba9e 1.4.4 2025-03-07 23:56:55 +08:00
ikun0014
8612fd0c94 VER 1.4.4 2025-03-07 23:56:51 +08:00
ikun0014
7fcbadabdf 1.4.3 2025-03-07 23:56:29 +08:00
ikun0014
6a21200ccc VER 1.4.3 2025-03-07 23:56:27 +08:00
ikun0014
0a384ce114 VER 1.4.3 2025-03-07 23:55:52 +08:00
4 changed files with 23 additions and 42 deletions

4
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"python.analysis.autoImportCompletions": true,
"python.analysis.typeCheckingMode": "basic"
}

View File

@@ -24,8 +24,7 @@ DEFAULT_CONFIG = {
"Custom_Steam_Path": "",
"Debug_Mode": False,
"Logging_Files": True,
"QA1": "Github Personal Token可在GitHub设置的Developer settings中生成",
"教程": "https://ikunshare.com/Onekey_tutorial",
"Help": "Github Personal Token可在GitHub设置的Developer settings中生成",
}

56
main.py
View File

@@ -36,11 +36,11 @@ def init() -> None:
\_____/ |_| \_| |_____| |_| \_\ |_____| /_/
"""
LOG.info(banner)
LOG.info("作者: ikun0014 | 版本: 1.4.1 | 官网: ikunshare.com")
LOG.info("作者: ikun0014 | 版本: 1.4.6 | 官网: ikunshare.com")
LOG.info("项目仓库: GitHub: https://github.com/ikunshare/Onekey")
LOG.info("ikunshare.com | 严禁倒卖")
LOG.info("提示: 请确保已安装Windows 10/11并正确配置Steam;SteamTools/GreenLuma")
LOG.info("开梯子必须配置Token, 你的IP我不相信能干净到哪")
LOG.warning("ikunshare.com | 严禁倒卖")
LOG.warning("提示: 请确保已安装Windows 10/11并正确配置Steam;SteamTools/GreenLuma")
LOG.warning("开梯子必须配置Token, 你的IP我不相信能干净到哪")
async def checkcn() -> bool:
@@ -59,6 +59,7 @@ async def checkcn() -> bool:
return True
except KeyboardInterrupt:
LOG.info("程序已退出")
return True
except httpx.ConnectError as e:
variable.IS_CN = True
LOG.warning("检查服务器位置失败,已忽略,自动认为你在中国大陆")
@@ -101,7 +102,7 @@ async def check_github_api_rate_limit(headers):
LOG.error(f"发生错误: {stack_error(e)}")
async def get_latest_repo_info(repos: list, app_id: str, headers) -> Any | None:
async def get_latest_repo_info(repos: list, app_id: str, headers) -> Any | str | None:
latest_date = None
selected_repo = None
for repo in repos:
@@ -111,9 +112,8 @@ async def get_latest_repo_info(repos: list, app_id: str, headers) -> Any | None:
if r_json and "commit" in r_json:
date = r_json["commit"]["commit"]["author"]["date"]
if (latest_date is None) or (date > latest_date):
latest_date = date
selected_repo = repo
latest_date = str(date)
selected_repo = str(repo)
return selected_repo, latest_date
@@ -125,7 +125,7 @@ async def handle_depot_files(
try:
selected_repo, latest_date = await get_latest_repo_info(
repos, app_id, headers=HEADER
)
) # type: ignore
if selected_repo:
branch_url = (
@@ -184,13 +184,12 @@ async def handle_depot_files(
LOG.error(f"HTTP错误: {e.response.status_code}")
except Exception as e:
LOG.error(f"文件处理失败: {str(e)}")
return collected, depot_map
return collected, depot_map # type: ignore
async def fetch_from_cdn(sha: str, path: str, repo: str):
if variable.IS_CN:
url_list = [
f"https://jsdelivr.pai233.top/gh/{repo}@{sha}/{path}",
f"https://cdn.jsdmirror.com/gh/{repo}@{sha}/{path}",
f"https://raw.gitmirror.com/{repo}/{sha}/{path}",
f"https://raw.dgithub.xyz/{repo}/{sha}/{path}",
@@ -237,15 +236,10 @@ async def setup_unlock_tool(
tool_choice: int,
depot_map: Dict,
) -> bool:
isGreenLuma = any(
(STEAM_PATH / dll).exists()
for dll in ["GreenLuma_2024_x86.dll", "GreenLuma_2024_x64.dll", "User32.dll"]
)
isSteamTools = (STEAM_PATH / "config" / "stUI").is_dir()
if (tool_choice == 1) and (isSteamTools):
if tool_choice == 1:
return await setup_steamtools(depot_data, app_id, depot_map)
elif (tool_choice == 2) and (isGreenLuma):
elif tool_choice == 2:
return await setup_greenluma(depot_data)
else:
LOG.error("你选的啥?")
@@ -258,7 +252,7 @@ async def setup_steamtools(
st_path = STEAM_PATH / "config" / "stplug-in"
st_path.mkdir(exist_ok=True)
choice = input(f"是否锁定版本(推荐在选择仓库1时使用)?(y/n): \n").lower()
choice = input(f"是否锁定版本(推荐在选择仓库1时使用)?(y/n): ").lower()
if choice == "y":
versionlock = True
@@ -277,22 +271,6 @@ async def setup_steamtools(
async with aiofiles.open(lua_file, "w") as f:
await f.write(lua_content)
proc = await asyncio.create_subprocess_exec(
str(st_path / "luapacka.exe"),
str(lua_file),
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
await proc.wait()
if proc.returncode != 0:
LOG.error(f"Lua编译失败: {await proc.stderr.read()}")
return False
if lua_file.exists():
os.remove(lua_file)
LOG.info(f"删除临时文件: {lua_file}")
return True
@@ -330,14 +308,14 @@ async def main_flow(app_id: str):
await checkcn()
await check_github_api_rate_limit(HEADER)
tool_choice = int(input("请选择解锁工具 (1.SteamTools 2.GreenLuma): \n"))
tool_choice = int(input("请选择解锁工具 (1.SteamTools 2.GreenLuma): "))
depot_data, depot_map = await handle_depot_files(REPO_LIST, app_id, STEAM_PATH)
if await setup_unlock_tool(depot_data, app_id, tool_choice, depot_map):
if await setup_unlock_tool(depot_data, app_id, tool_choice, depot_map): # type: ignore
LOG.info("游戏解锁配置成功!")
LOG.info("重启Steam后生效")
else:
LOG.error("配置失败,请检查日志")
LOG.error("配置失败")
os.system("pause")
return True
@@ -354,7 +332,7 @@ async def main_flow(app_id: str):
if __name__ == "__main__":
try:
init()
app_id = input(f"请输入游戏AppID: \n").strip()
app_id = input(f"请输入游戏AppID: ").strip()
asyncio.run(main_flow(app_id))
except (asyncio.CancelledError, KeyboardInterrupt):
os.system("pause")

View File

@@ -1,6 +1,6 @@
{
"name": "onekey",
"version": "1.4.2",
"version": "1.4.6",
"description": "一个Steam仓库清单下载器",
"main": "index.js",
"scripts": {