This commit is contained in:
pythoninthegrass 2024-02-20 23:31:06 -06:00
commit 6485a7c0ff
2 changed files with 39 additions and 30 deletions

View File

@ -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)
@ -905,15 +913,6 @@ if amazon_games:
# Push down when more scanners are added
#PipingInfoToDeckyPlugin
PIPE_PATH = "/tmp/NSLGameScanner_pipe"
# Check if the pipe does not exist
if not os.path.exists(PIPE_PATH):
# Create the named pipe
os.mkfifo(PIPE_PATH)
# Only write back to the shortcuts.vdf and config.vdf files if new shortcuts were added or compattools changed # Only write back to the shortcuts.vdf and config.vdf files if new shortcuts were added or compattools changed
if new_shortcuts_added or shortcuts_updated: if new_shortcuts_added or shortcuts_updated:
print(f"Saving new config and shortcuts files") print(f"Saving new config and shortcuts files")
@ -924,7 +923,7 @@ if new_shortcuts_added or shortcuts_updated:
file.write(vdf.binary_dumps(shortcuts)) file.write(vdf.binary_dumps(shortcuts))
# Load the configset_controller_neptune.vdf file # Load the configset_controller_neptune.vdf file
with open(controller_config_path, 'r') as f: with open(f"{controller_config_path}", 'r') as f:
config = vdf.load(f) config = vdf.load(f)
# Add new entries for the games # Add new entries for the games
@ -1007,7 +1006,7 @@ if new_shortcuts_added or shortcuts_updated:
} }
# Save the updated config # Save the updated config
with open(controller_config_path, 'w') as f: with open(f"{controller_config_path}", 'w') as f:
vdf.dump(config, f) vdf.dump(config, f)
# Print the created shortcuts # Print the created shortcuts
@ -1019,8 +1018,11 @@ if new_shortcuts_added or shortcuts_updated:
# Assuming 'games' is a list of game dictionaries # Assuming 'games' is a list of game dictionaries
games = [shortcut for shortcut in shortcuts['shortcuts'].values()] games = [shortcut for shortcut in shortcuts['shortcuts'].values()]
# Open the pipe for writing # Create the path to the output file
with open(PIPE_PATH, 'w') as pipe: output_file_path = f"{logged_in_home}/.config/systemd/user/NSLGameScanner_output.log"
# Open the output file in write mode
with open(output_file_path, 'w') as output_file:
for game in games: for game in games:
# Skip if 'appname' or 'exe' is None # Skip if 'appname' or 'exe' is None
if game.get('appname') is None or game.get('exe') is None: if game.get('appname') is None or game.get('exe') is None:
@ -1039,8 +1041,9 @@ if new_shortcuts_added or shortcuts_updated:
# Print the shortcut information in JSON format # Print the shortcut information in JSON format
message = json.dumps(shortcut_info) message = json.dumps(shortcut_info)
pipe.write(message + '\n') # Write to the pipe print(message, flush=True) # Print to stdout
# Print the shortcut information to the output file
print(message, file=output_file, flush=True)
print("All finished!") print("All finished!")

View File

@ -2720,18 +2720,24 @@ fi
# Directory to be checked
dir="${logged_in_home}/homebrew/plugins/NonSteamLaunchersDecky"
# Check if directory does not exist
if [ ! -d "$dir" ]; then
# Detach script from Steam process
nohup sh -c 'sleep 10; /usr/bin/steam' &
# Close all instances of Steam
steam_pid() { pgrep -x steam ; }
steam_running=$(steam_pid)
[[ -n "$steam_running" ]] && killall steam
# Wait for the steam process to exit
while steam_pid > /dev/null; do sleep 5; done
fi
# Detach script from Steam process
nohup sh -c 'sleep 10; /usr/bin/steam' &
# Close all instances of Steam
steam_pid() { pgrep -x steam ; }
steam_running=$(steam_pid)
[[ -n "$steam_running" ]] && killall steam
# Wait for the steam process to exit
while steam_pid > /dev/null; do sleep 5; done