From 8652259053c499ce2ca43ec0ff625768bd266e8d Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Wed, 8 Jul 2026 10:58:12 +0900 Subject: [PATCH] feat: convert appid to name --- dzgui/api/steam.py | 26 ++++++++++++++++++++++---- dzgui/const/endpoints.py | 1 + 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/dzgui/api/steam.py b/dzgui/api/steam.py index 9c4a941..2c6799a 100644 --- a/dzgui/api/steam.py +++ b/dzgui/api/steam.py @@ -23,9 +23,15 @@ from dzgui.const.constants import ( REQUEST_TIMEOUT, VDF_PATH, ) -from dzgui.const.endpoints import SUB_ENDPOINT, STEAM_PUBLISHED_FILES, UNSUB_ENDPOINT +from dzgui.const.endpoints import ( + APP_DETAILS, + SUB_ENDPOINT, + STEAM_PUBLISHED_FILES, + UNSUB_ENDPOINT, +) from dzgui.strings import wizard from dzgui.util.bash import concat_bash_args +from dzgui.util.strings import unknown logger = logging.getLogger(APP_NAME) @@ -292,9 +298,9 @@ def _get_running_app() -> int | None: if registry is None: return None try: - return int(registry["Registry"]["HKCU"]["Software"]["Valve"]["Steam"][ - "RunningAppID" - ]) + return int( + registry["Registry"]["HKCU"]["Software"]["Valve"]["Steam"]["RunningAppID"] + ) except Exception: return None @@ -391,3 +397,15 @@ def get_app_path(folders_path: Path, appid: int) -> Path: ) return Path(app_path) + + +def get_app_name(appid: int) -> str: + payload = {"appids": [appid]} + res = requests.get(APP_DETAILS, params=payload) + if res.status_code != 200: + return unknown + try: + return res.json()[str(appid)]["data"]["name"] + except Exception as e: + logger.debug(e) + return unknown diff --git a/dzgui/const/endpoints.py b/dzgui/const/endpoints.py index 9d15b02..26a50f8 100644 --- a/dzgui/const/endpoints.py +++ b/dzgui/const/endpoints.py @@ -5,6 +5,7 @@ STEAM_PUBLISHED_FILES = ( STEAM_SERVERS = "https://api.steampowered.com/IGameServersService/GetServerList/v1" SUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Subscribe/v1" UNSUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Unsubscribe/v1" +APP_DETAILS = "https://store.steampowered.com/api/appdetails?" BM_SERVERS = "https://api.battlemetrics.com/servers?" GITHUB = "https://github.com/aclist"