Skip to content

Commit

Permalink
SteamGridDB: Add --search-name option to commandlineGetSteamGridDBArt…
Browse files Browse the repository at this point in the history
…work (#938)
  • Loading branch information
sonic2kk authored Oct 17, 2023
1 parent 6cda7a0 commit b0ef25c
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
PREFIX="/usr"
PROGNAME="SteamTinkerLaunch"
NICEPROGNAME="Steam Tinker Launch"
PROGVERS="v14.0.20231018-2"
PROGVERS="v14.0.20231019-1"
PROGCMD="${0##*/}"
PROGINTERNALPROTNAME="Proton-stl"
SHOSTL="stl"
Expand Down Expand Up @@ -1533,12 +1533,17 @@ function commandlineGetSteamGridDBArtwork {
SGDBENDPOINTTYPE="steam" # assume Steam game by default (i.e. search Steam AppID endpoint)
GSGDBA_HASFILE="$SGDBHASFILE" # Optional override for how to handle if file already exists (downloadArtFromSteamGridDB defaults to '$SGDBHASFILE')
GSGDBA_APPLYARTWORK="$SGDBDLTOSTEAM"
GSGDBA_SEARCHNAME=""
GSGDBA_FOUNDGAMEID="" # ID found from SteamGridDB endpoint using GSGDBA_SEARCHNAME
for i in "${@}"; do
case $i in
--search-id=*) # ID to hit the SteamGridDB API endpoint with (for Steam games this is the AppID which we will also use as filename)
GSGDBA_APPID="${i#*=}"
GSGDBA_FILENAME="${GSGDBA_APPID}" # By default, file will be named <appid> with a suffix for each grid type (only non-steam games need this overridden since they search on Game ID and not Steam AppID)
shift ;;
--search-name=*)
GSGDBA_SEARCHNAME="${i#*=}" # Optional SteamGridDB Game Name -- Will use this to try and find matching SteamGridDB Game Art
shift ;;
--steam)
SGDBENDPOINTTYPE="steam" # used to generate the correct endpoint to hit, defaults to /heroes/game but this will make it heroes/steam
shift ;;
Expand Down Expand Up @@ -1571,6 +1576,23 @@ function commandlineGetSteamGridDBArtwork {
esac
done

# If we pass a name to search on and we get a Game ID back from SteamGridDB, set this as the ID to search for artwork on
if [ -n "$GSGDBA_SEARCHNAME" ]; then
if [ -n "$GSGDBA_FILENAME" ]; then
writelog "INFO" "${FUNCNAME[0]} - Searching SteamGridDB for game name matching '$GSGDBA_SEARCHNAME'"
GSGDBA_FOUNDGAMEID="$( getSGDBGameIDFromTitle "$GSGDBA_SEARCHNAME" )"
if [ -n "$GSGDBA_FOUNDGAMEID" ]; then
writelog "INFO" "${FUNCNAME[0]} - Found game name matching '$GSGDBA_SEARCHNAME' with Game ID '$GSGDBA_FOUNDGAMEID' -- Using this Game ID to search for SteamGridDB Game Art"
GSGDBA_APPID="$GSGDBA_FOUNDGAMEID"
writelog "INFO" "${FUNCNAME[0]} - Forcing endpoint type as --nonsteam since we're searching with a found SteamGridDB Game ID"
SGDBENDPOINTTYPE="game"
fi
else
writelog "ERROR" "${FUNCNAME[0]} - You must provide a filename AppID when searching with SteamGridDB Game Name"
echo "You must provide a filename AppID when searching with SteamGridDB Game Name"
fi
fi

SGDBSEARCHENDPOINT_HERO="${BASESTEAMGRIDDBAPI}/heroes/${SGDBENDPOINTTYPE}"
SGDBSEARCHENDPOINT_LOGO="${BASESTEAMGRIDDBAPI}/logos/${SGDBENDPOINTTYPE}"
SGDBSEARCHENDPOINT_BOXART="${BASESTEAMGRIDDBAPI}/grids/${SGDBENDPOINTTYPE}" # Grid endpoint is used for Boxart and Tenfoot, which SteamGridDB counts as vertical/horizontal grids respectively
Expand Down Expand Up @@ -21441,7 +21463,9 @@ function howto {
echo " to manage existing artwork files)."
echo " <args>:"
echo " --search-id= Steam AppID or SteamGridDB Game ID to search for (ex: AppID 22330 or Game ID 5258102)"
echo " --filename-appid= Steam AppID to use when naming the file, only required when searching on Game ID so the artwork is applied to the correct Shortcut"
echo " --search-name= Search SteamGridDB with a name and return the best-match Game ID, and use --nonsteam automatically."
echo " You must pass '--filename-appid' when using this option, otherwise artwork will use the wrong ID"
echo " --filename-appid= Steam AppID to use when naming the file, only required when searching on Game ID or Game Name so the artwork is applied to the correct Shortcut"
echo " --steam The Search ID passed is for a Steam AppID (default)"
echo " --nonsteam The Search ID passed is for a SteamGridDB Game ID"
echo " --apply Apply the downloaded game artwork to the Steam game (if not set, artwork will be downloaded to SteamTinkerLaunch Grid directory only)"
Expand Down

0 comments on commit b0ef25c

Please sign in to comment.