find local SteamAppId
This commit is contained in:
parent
fd0fa7d32c
commit
b58d7d8b6a
@ -51,13 +51,7 @@ getAppExe() {
|
|||||||
|
|
||||||
getAppTarget() {
|
getAppTarget() {
|
||||||
exe=$(getAppExe "$1")
|
exe=$(getAppExe "$1")
|
||||||
if [[ -n "${exe}" ]]; then
|
[[ -n "${exe}" ]] && parseSteamTargetExe "${exe}"
|
||||||
if [[ "${exe}" =~ .sh$ ]]; then
|
|
||||||
parseSteamTargetExe "${exe}"
|
|
||||||
else
|
|
||||||
echo "${exe}";
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSteamGameId() {
|
getSteamGameId() {
|
||||||
@ -73,15 +67,32 @@ getSteamId() {
|
|||||||
local cache_file="${PORT_WINE_TMP_PATH:-/tmp}/steamid_cache.json"
|
local cache_file="${PORT_WINE_TMP_PATH:-/tmp}/steamid_cache.json"
|
||||||
local applist_cache_file="${PORT_WINE_TMP_PATH:-/tmp}/steamapplist_cache.json"
|
local applist_cache_file="${PORT_WINE_TMP_PATH:-/tmp}/steamapplist_cache.json"
|
||||||
[[ -n "${1:-}" ]] && NOSTAPPNAME="$1"
|
[[ -n "${1:-}" ]] && NOSTAPPNAME="$1"
|
||||||
|
[[ -z "${NOSTAPPNAME}" ]] && return 1
|
||||||
if [[ -z "${SteamIds:-}" ]] && [[ -f "${cache_file}" ]]; then
|
if [[ -z "${SteamIds:-}" ]] && [[ -f "${cache_file}" ]]; then
|
||||||
SteamIds=$(<"${cache_file}")
|
SteamIds=$(<"${cache_file}")
|
||||||
fi
|
fi
|
||||||
if [[ -n "${SteamIds:-}" ]] && jq -e --arg key "${NOSTAPPNAME}" 'has($key)' <<< "${SteamIds}" > /dev/null; then
|
if [[ -n "${1:-}" ]] && [[ -n "${SteamIds:-}" ]] && jq -e --arg key "${NOSTAPPNAME}" 'has($key)' <<< "${SteamIds}" > /dev/null; then
|
||||||
SteamAppId=$(jq -r --arg key "${NOSTAPPNAME}" '.[$key]' <<< "${SteamIds}")
|
SteamAppId=$(jq -r --arg key "${NOSTAPPNAME}" '.[$key]' <<< "${SteamIds}")
|
||||||
else
|
else
|
||||||
if [[ -n "${1:-}" ]] && [[ "${USE_STEAMGRIDDB:-1}" == "1" ]]; then
|
if [[ -n "${2:-}" ]]; then
|
||||||
getSteamGridDBId "${NOSTAPPNAME}" > /dev/null
|
NOSTAPPPATH="$2"
|
||||||
|
[[ -f "${NOSTAPPPATH}.ppdb" ]] && source "${NOSTAPPPATH}.ppdb"
|
||||||
fi
|
fi
|
||||||
|
[[ -n "${STEAM_APP_ID:-}" ]] && SteamAppId="${STEAM_APP_ID}"
|
||||||
|
if [[ -z "${SteamAppId:-}" ]] && [[ -n "${NOSTAPPPATH:-}" ]]; then
|
||||||
|
local paths=("steam_appid.txt" "steam_emu.ini" "steam_api.ini" "steam_api64.ini")
|
||||||
|
local conditions=$(printf " -o -name %q" "${paths[@]}")
|
||||||
|
local file=$(find "$(dirname "${NOSTAPPPATH}")" -type f \( ${conditions# -o} \) -print -quit 2>/dev/null)
|
||||||
|
if [[ -n "${file}" ]]; then
|
||||||
|
if [[ "${file}" == *"steam_appid.txt" ]]; then
|
||||||
|
SteamAppId=$(cat "${file}" | tr -d '\r\n')
|
||||||
|
else
|
||||||
|
SteamAppId=$(grep -i "^AppId=" "${file}" | cut -d'=' -f2 | head -1 | tr -d '\r\n')
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ -z "${SteamAppId:-}" ]]; then
|
||||||
|
[[ "${USE_STEAMGRIDDB:-1}" == "1" ]] && getSteamGridDBId "${NOSTAPPNAME}" > /dev/null
|
||||||
if [[ ${SteamGridDBTypeSteam} == true ]]; then
|
if [[ ${SteamGridDBTypeSteam} == true ]]; then
|
||||||
SRES=$(curl -Ls --connect-timeout 5 -m 10 -e "https://www.steamgriddb.com/game/${SteamGridDBId}" "https://www.steamgriddb.com/api/public/game/${SteamGridDBId}")
|
SRES=$(curl -Ls --connect-timeout 5 -m 10 -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
|
if jq -e ".success == true" <<< "${SRES}" > /dev/null 2>&1; then
|
||||||
@ -96,6 +107,7 @@ getSteamId() {
|
|||||||
fi
|
fi
|
||||||
[[ -n "${applist_data}" ]] && SteamAppId=$(jq --arg name "${NOSTAPPNAME,,}" '.applist.apps[] | select(.name == $name) | .appid' <<< "${applist_data,,}")
|
[[ -n "${applist_data}" ]] && SteamAppId=$(jq --arg name "${NOSTAPPNAME,,}" '.applist.apps[] | select(.name == $name) | .appid' <<< "${applist_data,,}")
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
SteamIds=$(jq --arg key "${NOSTAPPNAME}" --arg value "${SteamAppId:-}" '. + {($key): $value}' <<< "${SteamIds:-$(jq -n '{}')}")
|
SteamIds=$(jq --arg key "${NOSTAPPNAME}" --arg value "${SteamAppId:-}" '. + {($key): $value}' <<< "${SteamIds:-$(jq -n '{}')}")
|
||||||
echo "${SteamIds}" > "${cache_file}"
|
echo "${SteamIds}" > "${cache_file}"
|
||||||
fi
|
fi
|
||||||
@ -178,11 +190,7 @@ getUserPath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSteamPath() {
|
getSteamPath() {
|
||||||
local paths=(
|
local paths=("${HOME}/.steam/steam" "${HOME}/.local/share/Steam" "${HOME}/.var/app/com.valvesoftware.Steam/.steam/steam")
|
||||||
"${HOME}/.steam/steam"
|
|
||||||
"${HOME}/.local/share/Steam"
|
|
||||||
"${HOME}/.var/app/com.valvesoftware.Steam/.steam/steam"
|
|
||||||
)
|
|
||||||
for path in "${paths[@]}"; do
|
for path in "${paths[@]}"; do
|
||||||
if [[ -d "${path}" ]]; then
|
if [[ -d "${path}" ]]; then
|
||||||
STEAM_BASE_FOLDER="${path}"
|
STEAM_BASE_FOLDER="${path}"
|
||||||
@ -237,7 +245,8 @@ listSteamGames() {
|
|||||||
appid="${name}"
|
appid="${name}"
|
||||||
name=$(basename "${exe}" .sh)
|
name=$(basename "${exe}" .sh)
|
||||||
else
|
else
|
||||||
appid="$(getSteamId "${name}")"
|
path="$(parseSteamTargetExe "${exe}")"
|
||||||
|
appid="$(getSteamId "${name}" "${path}")"
|
||||||
[[ -z "${appid}" ]] && appid="0"
|
[[ -z "${appid}" ]] && appid="0"
|
||||||
fi
|
fi
|
||||||
gid="$(getSteamGameId $id)"
|
gid="$(getSteamGameId $id)"
|
||||||
@ -302,7 +311,9 @@ parseSteamShortcutEntryLaunchOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseSteamTargetExe() {
|
parseSteamTargetExe() {
|
||||||
|
if [[ "$1" =~ .sh$ ]]; then
|
||||||
grep -E '^[^# ]*?(flatpak|start\.sh)' "$1" | head -n 1 | sed 's/ "\$@"//' | awk -F'"' '{print $(NF-1)}'
|
grep -E '^[^# ]*?(flatpak|start\.sh)' "$1" | head -n 1 | sed 's/ "\$@"//' | awk -F'"' '{print $(NF-1)}'
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
restartSteam() {
|
restartSteam() {
|
||||||
@ -333,9 +344,6 @@ downloadImage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadImageSteam() {
|
downloadImageSteam() {
|
||||||
if [[ -z "${SteamAppId}" ]]; then
|
|
||||||
getSteamId > /dev/null
|
|
||||||
fi
|
|
||||||
if [[ -n "${SteamAppId}" ]]; then
|
if [[ -n "${SteamAppId}" ]]; then
|
||||||
downloadImage "https://cdn.cloudflare.steamstatic.com/steam/apps/${SteamAppId}/$1" "$2"
|
downloadImage "https://cdn.cloudflare.steamstatic.com/steam/apps/${SteamAppId}/$1" "$2"
|
||||||
else
|
else
|
||||||
@ -363,16 +371,22 @@ downloadImageSteamGridDB() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addGrids() {
|
addGrids() {
|
||||||
[[ -z "${SteamGridDBId}" ]] && getSteamGridDBId "${name_desktop}" > /dev/null
|
local AppId="${NOSTAPPID:-0}"
|
||||||
if [[ -z "${SteamAppId}" ]] && [[ "${USE_STEAMGRIDDB:-1}" == "0" ]]; then
|
local in=("header.jpg" "library_600x900_2x.jpg" "library_hero.jpg" "logo.png")
|
||||||
|
local out=("${AppId}.jpg" "${AppId}"p".jpg" "${AppId}"_hero".jpg" "${AppId}"_logo".png")
|
||||||
|
local gtype=("grids" "grids" "heroes" "logos")
|
||||||
|
local mimes=("image/jpeg" "image/jpeg" "image/jpeg" "image/png")
|
||||||
|
local dims=("460x215,920x430" "600x900,660x930" "" "")
|
||||||
|
if [[ -z "${SteamGridDBId}" ]] && [[ -z "${SteamAppId}" ]]; then
|
||||||
getSteamId > /dev/null
|
getSteamId > /dev/null
|
||||||
fi
|
fi
|
||||||
if [[ -n "${SteamGridDBId}" ]] || [[ -n "${SteamAppId}" ]]; then
|
if [[ -n "${SteamGridDBId}" ]] || [[ -n "${SteamAppId}" ]]; then
|
||||||
create_new_dir "${STCFGPATH}/grid"
|
create_new_dir "${STCFGPATH}/grid"
|
||||||
downloadImageSteamGridDB "grids" "${NOSTAPPID:-0}.jpg" "mimes=image/jpeg" "dimensions=460x215,920x430" || downloadImageSteam "header.jpg" "${NOSTAPPID:-0}.jpg" || echo "Failed to load header.jpg"
|
for i in {0..3}; do
|
||||||
downloadImageSteamGridDB "grids" "${NOSTAPPID:-0}p.jpg" "mimes=image/jpeg" "dimensions=600x900,660x930" || downloadImageSteam "library_600x900_2x.jpg" "${NOSTAPPID:-0}p.jpg" || echo "Failed to load library_600x900_2x.jpg"
|
downloadImageSteam "${in[${i}]}" "${out[${i}]}" || \
|
||||||
downloadImageSteamGridDB "heroes" "${NOSTAPPID:-0}_hero.jpg" "mimes=image/jpeg" || downloadImageSteam "library_hero.jpg" "${NOSTAPPID:-0}_hero.jpg" || echo "Failed to load library_hero.jpg"
|
downloadImageSteamGridDB "${gtype[${i}]}" "${out[${i}]}" ${mimes[${i}]:+"mimes=${mimes[${i}]}"} ${dims[${i}]:+"dimensions=${dims[${i}]}"} || \
|
||||||
downloadImageSteamGridDB "logos" "${NOSTAPPID:-0}_logo.png" "mimes=image/png" || downloadImageSteam "logo.png" "${NOSTAPPID:-0}_logo.png" || echo "Failed to load logo.png"
|
echo "Failed to load ${in[${i}]}"
|
||||||
|
done
|
||||||
else
|
else
|
||||||
echo "Game is not found"
|
echo "Game is not found"
|
||||||
fi
|
fi
|
||||||
@ -474,6 +488,7 @@ addNonSteamGame() {
|
|||||||
if [[ -n "${SCPATH}" ]]; then
|
if [[ -n "${SCPATH}" ]]; then
|
||||||
[[ -z "${NOSTSHPATH}" ]] && NOSTSHPATH="${STEAM_SCRIPTS}/${name_desktop}.sh"
|
[[ -z "${NOSTSHPATH}" ]] && NOSTSHPATH="${STEAM_SCRIPTS}/${name_desktop}.sh"
|
||||||
NOSTAPPNAME="${name_desktop}"
|
NOSTAPPNAME="${name_desktop}"
|
||||||
|
NOSTAPPPATH="${portwine_exe}"
|
||||||
NOSTAPPID=$(getAppId "${NOSTSHPATH}")
|
NOSTAPPID=$(getAppId "${NOSTSHPATH}")
|
||||||
if [[ ! -f "${NOSTSHPATH}" ]]; then
|
if [[ ! -f "${NOSTSHPATH}" ]]; then
|
||||||
create_new_dir "${STEAM_SCRIPTS}"
|
create_new_dir "${STEAM_SCRIPTS}"
|
||||||
@ -482,7 +497,7 @@ addNonSteamGame() {
|
|||||||
export LD_PRELOAD=
|
export LD_PRELOAD=
|
||||||
export START_FROM_STEAM=1
|
export START_FROM_STEAM=1
|
||||||
export START_FROM_FLATPAK=$(check_flatpak && echo 1 || echo 0)
|
export START_FROM_FLATPAK=$(check_flatpak && echo 1 || echo 0)
|
||||||
"${PORT_SCRIPTS_PATH}/start.sh" "${portwine_exe}" "\$@"
|
"${PORT_SCRIPTS_PATH}/start.sh" "${NOSTAPPPATH}" "\$@"
|
||||||
EOF
|
EOF
|
||||||
chmod u+x "${NOSTSHPATH}"
|
chmod u+x "${NOSTSHPATH}"
|
||||||
fi
|
fi
|
||||||
@ -498,7 +513,7 @@ addNonSteamGame() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${USE_STEAMAPPID_AS_NAME:-0}" == "1" ]]; then
|
if [[ "${USE_STEAMAPPID_AS_NAME:-0}" == "1" ]]; then
|
||||||
SteamAppId=$(getSteamId "${NOSTAPPNAME}")
|
getSteamId > /dev/null
|
||||||
[[ -n "${SteamAppId}" ]] && NOSTAPPNAME="${SteamAppId}"
|
[[ -n "${SteamAppId}" ]] && NOSTAPPNAME="${SteamAppId}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user