Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
added fixes for network errors and nexon and repair ea app
  • Loading branch information
moraroy authored Aug 2, 2024
1 parent 57e3681 commit b8245e9
Showing 1 changed file with 45 additions and 29 deletions.
74 changes: 45 additions & 29 deletions NSLGameScanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
psplusshortcutdirectory = os.environ.get('psplusshortcutdirectory')
vkplayshortcutdirectory = os.environ.get('vkplayshortcutdirectory')
hoyoplayshortcutdirectory = os.environ.get('hoyoplayshortcutfirectory')
nexonshortcutdirectory = os.environ.get('nexonshortcutdirectory')
repaireaappshortcutdirectory = os.environ.get('repaireaappshortcutdirectory')
#Streaming
chromedirectory = os.environ.get('chromedirectory')
websites_str = os.environ.get('custom_websites_str')
Expand Down Expand Up @@ -158,7 +160,6 @@




#Code
def get_steam_shortcut_id(exe_path, display_name):
unique_id = "".join([exe_path, display_name])
Expand All @@ -176,8 +177,8 @@ def get_unsigned_shortcut_id(signed_shortcut_id):
api_cache = {}

#API KEYS FOR NONSTEAMLAUNCHER USE ONLY
sgdb = SteamGridDB('36e4bedbfdda27f42f9ef4a44f80955c')
api_key = '36e4bedbfdda27f42f9ef4a44f80955c'
sgdb = SteamGridDB('e3bf9f166d7a80ae260387f90e36d10e')
api_key = 'e3bf9f166d7a80ae260387f90e36d10e'

#GLOBAL VARS
created_shortcuts = []
Expand Down Expand Up @@ -272,24 +273,29 @@ def download_artwork(game_id, api_key, art_type, shortcut_id, dimensions=None):
if cache_key in api_cache:
data = api_cache[cache_key]
else:
# If the result is not in the cache, make the API call
print(f"Game ID: {game_id}, API Key: {api_key}")
url = f"https://www.steamgriddb.com/api/v2/{art_type}/game/{game_id}"
if dimensions:
url += f"?dimensions={dimensions}"
headers = {'Authorization': f'Bearer {api_key}'}
print(f"Sending request to: {url}") # Added print statement
response = requests.get(url, headers=headers)
if response.status_code == 200:
try:
# If the result is not in the cache, make the API call
print(f"Game ID: {game_id}, API Key: {api_key}")
url = f"https://www.steamgriddb.com/api/v2/{art_type}/game/{game_id}"
if dimensions:
url += f"?dimensions={dimensions}"
headers = {'Authorization': f'Bearer {api_key}'}
print(f"Sending request to: {url}") # Added print statement
response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()
# Store the result in the cache
api_cache[cache_key] = data
else:
print(f"Error making API call: {response.status_code}")
# Store the failed status in the cache
except Exception as e: # Catching a general exception
print(f"Error making API call: {e}")
api_cache[cache_key] = None
return

# Ensure data is not None before proceeding
if data is None:
print(f"No data available for {game_id}. Skipping download.")
return

# Continue with the rest of your function using `data`
for artwork in data['data']:
image_url = artwork['thumb']
Expand All @@ -307,19 +313,27 @@ def download_artwork(game_id, api_key, art_type, shortcut_id, dimensions=None):
download_artwork(game_id, api_key, 'icons_ico', shortcut_id)




def get_game_id(game_name):
print(f"Searching for game ID for: {game_name}")
games = sgdb.search_game(game_name)
for game in games:
if game.name == game_name: # Case-sensitive comparison
print(f"Found game ID: {game.id}")
return game.id
# Fallback: return the ID of the first game in the search results
if games:
print(f"No exact match found. Using game ID of the first result: {games[0].name}: {games[0].id}")
return games[0].id
print("No game ID found")
return "default_game_id" # Return a default value when no games are found
try:
games = sgdb.search_game(game_name)
for game in games:
if game.name == game_name: # Case-sensitive comparison
print(f"Found game ID: {game.id}")
return game.id
# Fallback: return the ID of the first game in the search results
if games:
print(f"No exact match found. Using game ID of the first result: {games[0].name}: {games[0].id}")
return games[0].id
print("No game ID found")
return "default_game_id" # Return a default value when no games are found
except Exception as e: # Catching a general exception
print(f"Error searching for game ID: {e}")
return "default_game_id" # Return a default value in case of an error



def get_file_name(art_type, shortcut_id, dimensions=None):
singular_art_type = art_type.rstrip('s')
Expand All @@ -346,6 +360,7 @@ def is_match(name1, name2):
else:
return False


# Add or update the proton compatibility settings
def add_compat_tool(app_id, launchoptions):
if 'CompatToolMapping' not in config_data['InstallConfigStore']['Software']['Valve']['Steam']:
Expand Down Expand Up @@ -412,7 +427,7 @@ def create_new_entry(shortcutdirectory, appname, launchoptions, startingdir):
signed_shortcut_id = get_steam_shortcut_id(exe_path, appname)
unsigned_shortcut_id = get_unsigned_shortcut_id(signed_shortcut_id)
# Only store the app ID for specific launchers
if appname in ['Epic Games', 'Gog Galaxy', 'Ubisoft Connect', 'Battle.net', 'EA App', 'Amazon Games', 'itch.io', 'Legacy Games', 'Humble Bundle', 'IndieGala Client', 'Rockstar Games Launcher', 'Glyph', 'Playstation Plus', 'VK Play', 'HoYoPlay']:
if appname in ['Epic Games', 'Gog Galaxy', 'Ubisoft Connect', 'Battle.net', 'EA App', 'Amazon Games', 'itch.io', 'Legacy Games', 'Humble Bundle', 'IndieGala Client', 'Rockstar Games Launcher', 'Glyph', 'Playstation Plus', 'VK Play', 'HoYoPlay', 'Nexon Launcher']:
app_ids[appname] = unsigned_shortcut_id

# Check if the game already exists in the shortcuts
Expand Down Expand Up @@ -489,6 +504,8 @@ def create_new_entry(shortcutdirectory, appname, launchoptions, startingdir):
create_new_entry(os.environ.get('psplusshortcutdirectory'), 'Playstation Plus', os.environ.get('pspluslaunchoptions'), os.environ.get('psplusstartingdir'))
create_new_entry(os.environ.get('vkplayshortcutdirectory'), 'VK Play', os.environ.get('vkplaylaunchoptions'), os.environ.get('vkplaystartingdir'))
create_new_entry(os.environ.get('hoyoplayshortcutdirectory'), 'HoYoPlay', os.environ.get('hoyoplaylaunchoptions'), os.environ.get('hoyoplaystartingdir'))
create_new_entry(os.environ.get('nexonshortcutdirectory'), 'Nexon Launcher', os.environ.get('nexonlaunchoptions'), os.environ.get('nexonstartingdir'))
create_new_entry(os.environ.get('repaireaappshortcutdirectory'), 'Repair EA App', os.environ.get('repaireaapplaunchoptions'), os.environ.get('repaireaappstartingdir'))
create_new_entry(os.environ.get('chromedirectory'), 'Xbox Game Pass', os.environ.get('xboxchromelaunchoptions'), os.environ.get('chrome_startdir'))
create_new_entry(os.environ.get('chromedirectory'), 'GeForce Now', os.environ.get('geforcechromelaunchoptions'), os.environ.get('chrome_startdir'))
create_new_entry(os.environ.get('chromedirectory'), 'Netflix', os.environ.get('netflixchromelaunchoptions'), os.environ.get('chrome_startdir'))
Expand All @@ -498,7 +515,6 @@ def create_new_entry(shortcutdirectory, appname, launchoptions, startingdir):
create_new_entry(os.environ.get('chromedirectory'), 'Youtube', os.environ.get('youtubechromelaunchoptions'), os.environ.get('chrome_startdir'))
create_new_entry(os.environ.get('chromedirectory'), 'Amazon Luna', os.environ.get('lunachromelaunchoptions'), os.environ.get('chrome_startdir'))
create_new_entry(os.environ.get('chromedirectory'), 'Twitch', os.environ.get('twitchchromelaunchoptions'), os.environ.get('chrome_startdir'))
create_new_entry(os.environ.get('chromedirectory'), 'movie-web', os.environ.get('moviewebchromelaunchoptions'), os.environ.get('chrome_startdir'))
create_new_entry(os.environ.get('chromedirectory'), 'Fortnite', os.environ.get('fortnitechromelaunchoptions'), os.environ.get('chrome_startdir'))


Expand Down Expand Up @@ -598,6 +614,7 @@ def create_new_entry(shortcutdirectory, appname, launchoptions, startingdir):
'Playstation Plus': 'PlaystationPlusLauncher',
'VK Play': 'VKPlayLauncher',
'HoYoPlay': 'HoYoPlayLauncher',
'Nexon Launcher': 'NexonLauncher',
}


Expand Down Expand Up @@ -1311,4 +1328,3 @@ def dbpath_to_game(paths):
print(f"Error writing to output file: {e}")

print("All finished!")

0 comments on commit b8245e9

Please sign in to comment.