mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 01:37:18 +02:00
feat: convert appid to name
This commit is contained in:
parent
eff31e2bd3
commit
8652259053
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user