From b0ef25c84fb6c888b3cec59bc42e7823ec845e0e Mon Sep 17 00:00:00 2001 From: Eamonn Rea Date: Tue, 17 Oct 2023 23:11:44 +0100 Subject: [PATCH] SteamGridDB: Add --search-name option to commandlineGetSteamGridDBArtwork (#938) --- steamtinkerlaunch | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/steamtinkerlaunch b/steamtinkerlaunch index 472ede52..4fa205be 100755 --- a/steamtinkerlaunch +++ b/steamtinkerlaunch @@ -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" @@ -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 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 ;; @@ -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 @@ -21441,7 +21463,9 @@ function howto { echo " to manage existing artwork files)." echo " :" 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)"