From bca5c38922d3a876662bc14bc22f004e459dba58 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Sun, 3 Nov 2024 00:12:22 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B0=D0=BB=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_from_portwine/scripts/get_images.sh | 61 ++++++++++++++++++++++++ data_from_portwine/scripts/var | 1 + 2 files changed, 62 insertions(+) create mode 100755 data_from_portwine/scripts/get_images.sh diff --git a/data_from_portwine/scripts/get_images.sh b/data_from_portwine/scripts/get_images.sh new file mode 100755 index 00000000..4a4be5d7 --- /dev/null +++ b/data_from_portwine/scripts/get_images.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# AppName= AppId= SteamAppId= SteamGridDBId= SGGRIDDIR= ./get_images.sh + +if [[ -z "${SGDBAPIKEY}" || -z "${BASESTEAMGRIDDBAPI}" ]]; then + source "${PORT_SCRIPTS_PATH:-$(dirname "$(readlink --canonicalize-existing "$0")")}/var" +fi + +function downloadImage { + local path="${SGGRIDDIR:-${PWD}}" + local url="$1" + local files="$2" + local cur=''; + if [[ -n "${url}" && -n "${files}" ]]; then + for file in ${files[@]}; do + if [[ -z "$cur" ]]; then + curl -Lf# -o "${path}/${file}" "${url}" + else + cp "${path}/${cur}" "${path}/${file}" + fi + cur="${file}" + done + fi +} + +function downloadImageSteam { + downloadImage "https://cdn.cloudflare.steamstatic.com/steam/apps/$1" "$2" +} + +function downloadImageSteamgriddb { + SGDBIMGRES=$(curl -Ls -H "Authorization: Bearer ${SGDBAPIKEY}" "${BASESTEAMGRIDDBAPI}/$1&limit=1") + if jq -e ".success == true and (.data | length > 0)" <<< "${SGDBIMGRES}" > /dev/null 2>&1; then + SGDBIMGURL=$(jq -r '.data[0].url' <<< "${SGDBIMGRES}") + downloadImage "${SGDBIMGURL}" "$2" + fi +} + +if [[ -z "${SteamAppId}" && -z "${SteamGridDBId}" && -n "${AppName}" && -n "${SGDBAPIKEY}" ]]; then + SGDBRES=$(curl -Ls -H "Authorization: Bearer ${SGDBAPIKEY}" "${BASESTEAMGRIDDBAPI}/search/autocomplete/${AppName// /_}") + if jq -e ".success == true and (.data | length > 0)" <<< "${SGDBRES}" > /dev/null 2>&1; then + export SteamGridDBId="$(jq '.data[0].id' <<< "${SGDBRES}")" + if jq -e '.data[0].types | contains(["steam"])' <<< "${SGDBRES}" > /dev/null; 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 + export SteamAppId="$(jq -r '.data.platforms.steam.id' <<< "${SRES}")" + fi + fi + fi +fi + +if [[ -n "${SteamAppId}" ]]; then + downloadImageSteam "${SteamAppId}/header.jpg" "${AppId:-0}.jpg" + downloadImageSteam "${SteamAppId}/library_600x900_2x.jpg" "${AppId:-0}p.jpg" + downloadImageSteam "${SteamAppId}/library_hero.jpg" "${AppId:-0}_hero.jpg" + downloadImageSteam "${SteamAppId}/logo.png" "${AppId:-0}_logo.png" +elif [[ -n "${SteamGridDBId}" && -n "${SGDBAPIKEY}" ]]; then + downloadImageSteamgriddb "grids/game/${SteamGridDBId}?mimes=image/jpeg" "${AppId:-0}.jpg ${AppId:-0}p.jpg" + downloadImageSteamgriddb "heroes/game/${SteamGridDBId}?mimes=image/jpeg" "${AppId:-0}_hero.jpg" + downloadImageSteamgriddb "logos/game/${SteamGridDBId}?mimes=image/png" "${AppId:-0}_logo.png" +else + echo "Game is not found" +fi diff --git a/data_from_portwine/scripts/var b/data_from_portwine/scripts/var index 74e9fba4..b600c10c 100755 --- a/data_from_portwine/scripts/var +++ b/data_from_portwine/scripts/var @@ -137,6 +137,7 @@ export DEFPFX_VER="v1" export PW_MUST_WINEDLLOVERRIDES="steam_api,steam_api64,steamclient,steamclient64=n;dotnetfx35.exe,dotnetfx35setup.exe=b;winemenubuilder.exe=" ################################################################# # Get our APi on https://www.steamgriddb.com/profile/preferences/api/ +export BASESTEAMGRIDDBAPI="https://www.steamgriddb.com/api/v2" export SGDBAPIKEY="4a022f8848eaaa8e9c30067cd6676129" ################################################################# export DXVK_CONFIG_FILE="${PORT_WINE_PATH}/data/dxvk.conf"