cache on getSteamId
This commit is contained in:
parent
aea3d99a9d
commit
b4a5190c0f
@ -92,16 +92,28 @@ getAppId() {
|
|||||||
|
|
||||||
getSteamId() {
|
getSteamId() {
|
||||||
unset SteamAppId
|
unset SteamAppId
|
||||||
NOSTAPPNAME="$1"
|
local cache_file="${PORT_WINE_TMP_PATH:-/tmp}/steamid_cache.json"
|
||||||
if [[ -n "${NOSTAPPNAME}" ]]; then
|
[[ -n "${1:-}" ]] && NOSTAPPNAME="$1"
|
||||||
getSteamGridDBId "${NOSTAPPNAME}" > /dev/null
|
if [[ -z "${SteamIds:-}" ]] && [[ -f "${cache_file}" ]]; then
|
||||||
|
SteamIds=$(<"${cache_file}")
|
||||||
fi
|
fi
|
||||||
if [[ $SteamGridDBTypeSteam == true ]]; then
|
if [[ -n "${SteamIds:-}" ]] && jq -e --arg key "$NOSTAPPNAME" 'has($key)' <<< "${SteamIds}" > /dev/null; then
|
||||||
SRES=$(curl -Ls -e "https://www.steamgriddb.com/game/${SteamGridDBId}" "https://www.steamgriddb.com/api/public/game/${SteamGridDBId}")
|
SteamAppId=$(jq -r --arg key "${NOSTAPPNAME}" '.[$key]' <<< "${SteamIds}")
|
||||||
if jq -e ".success == true" <<< "${SRES}" > /dev/null 2>&1; then
|
else
|
||||||
SteamAppId="$(jq -r '.data.platforms.steam.id' <<< "${SRES}")"
|
if [[ -n "${1:-}" ]]; then
|
||||||
echo ${SteamAppId}
|
getSteamGridDBId "${NOSTAPPNAME}" > /dev/null
|
||||||
fi
|
fi
|
||||||
|
if [[ $SteamGridDBTypeSteam == true ]]; then
|
||||||
|
SRES=$(curl -Ls -e "https://www.steamgriddb.com/game/${SteamGridDBId}" "https://www.steamgriddb.com/api/public/game/${SteamGridDBId}")
|
||||||
|
if jq -e ".success == true" <<< "${SRES}" > /dev/null 2>&1; then
|
||||||
|
SteamAppId="$(jq -r '.data.platforms.steam.id' <<< "${SRES}")"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
SteamIds=$(jq --arg key "${NOSTAPPNAME}" --arg value "${SteamAppId:-}" '. + {($key): $value}' <<< "${SteamIds:-$(jq -n '{}')}")
|
||||||
|
echo "${SteamIds}" > "${cache_file}"
|
||||||
|
fi
|
||||||
|
if [[ -n "${SteamAppId:-}" ]]; then
|
||||||
|
echo "${SteamAppId}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +128,7 @@ getSteamGridDBId() {
|
|||||||
SteamGridDBTypeSteam=false
|
SteamGridDBTypeSteam=false
|
||||||
fi
|
fi
|
||||||
SteamGridDBId="$(jq '.data[0].id' <<< "${SGDBRES}")"
|
SteamGridDBId="$(jq '.data[0].id' <<< "${SGDBRES}")"
|
||||||
echo ${SteamGridDBId}
|
echo "${SteamGridDBId}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user