mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 15:21:52 +01:00
lessened api calls
This commit is contained in:
parent
bdc2ed7b12
commit
aa290fee94
@ -155,8 +155,8 @@ def get_unsigned_shortcut_id(signed_shortcut_id):
|
|||||||
api_cache = {}
|
api_cache = {}
|
||||||
|
|
||||||
#API KEYS FOR NONSTEAMLAUNCHER USE ONLY
|
#API KEYS FOR NONSTEAMLAUNCHER USE ONLY
|
||||||
sgdb = SteamGridDB('8d4131fd8213502c20276b738f7acb1a')
|
sgdb = SteamGridDB('36e4bedbfdda27f42f9ef4a44f80955c')
|
||||||
api_key = '8d4131fd8213502c20276b738f7acb1a'
|
api_key = '36e4bedbfdda27f42f9ef4a44f80955c'
|
||||||
|
|
||||||
#GLOBAL VARS
|
#GLOBAL VARS
|
||||||
created_shortcuts = []
|
created_shortcuts = []
|
||||||
@ -180,6 +180,8 @@ def get_sgdb_art(game_id, app_id):
|
|||||||
print("Downloading grids artwork of size 920x430...")
|
print("Downloading grids artwork of size 920x430...")
|
||||||
download_artwork(game_id, api_key, "grids", app_id, "920x430")
|
download_artwork(game_id, api_key, "grids", app_id, "920x430")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def download_artwork(game_id, api_key, art_type, shortcut_id, dimensions=None):
|
def download_artwork(game_id, api_key, art_type, shortcut_id, dimensions=None):
|
||||||
# Create a cache key based on the function's arguments
|
# Create a cache key based on the function's arguments
|
||||||
cache_key = (game_id, art_type, dimensions)
|
cache_key = (game_id, art_type, dimensions)
|
||||||
@ -215,6 +217,11 @@ def download_artwork(game_id, api_key, art_type, shortcut_id, dimensions=None):
|
|||||||
data = response.json()
|
data = response.json()
|
||||||
# Store the result in the cache
|
# Store the result in the cache
|
||||||
api_cache[cache_key] = data
|
api_cache[cache_key] = data
|
||||||
|
else:
|
||||||
|
print(f"Error making API call: {response.status_code}")
|
||||||
|
# Store the failed status in the cache
|
||||||
|
api_cache[cache_key] = None
|
||||||
|
return
|
||||||
|
|
||||||
# Continue with the rest of your function using `data`
|
# Continue with the rest of your function using `data`
|
||||||
for artwork in data['data']:
|
for artwork in data['data']:
|
||||||
@ -232,6 +239,7 @@ def download_artwork(game_id, api_key, art_type, shortcut_id, dimensions=None):
|
|||||||
if art_type == 'icons':
|
if art_type == 'icons':
|
||||||
download_artwork(game_id, api_key, 'icons_ico', shortcut_id)
|
download_artwork(game_id, api_key, 'icons_ico', shortcut_id)
|
||||||
|
|
||||||
|
|
||||||
def get_game_id(game_name):
|
def get_game_id(game_name):
|
||||||
print(f"Searching for game ID for: {game_name}")
|
print(f"Searching for game ID for: {game_name}")
|
||||||
games = sgdb.search_game(game_name)
|
games = sgdb.search_game(game_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user