mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2025-01-20 22:01:12 +01:00
Update NSLGameScanner.py
This commit is contained in:
parent
f820d1dd58
commit
c33fbb36f2
@ -257,20 +257,17 @@ def download_artwork(game_id, art_type, shortcut_id, dimensions=None):
|
|||||||
filename = get_file_name(art_type, shortcut_id, dimensions)
|
filename = get_file_name(art_type, shortcut_id, dimensions)
|
||||||
else:
|
else:
|
||||||
filename = get_file_name(art_type, shortcut_id)
|
filename = get_file_name(art_type, shortcut_id)
|
||||||
|
|
||||||
file_path = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{filename}"
|
file_path = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{filename}"
|
||||||
directory = os.path.dirname(file_path)
|
|
||||||
|
|
||||||
|
directory = os.path.dirname(file_path)
|
||||||
if not os.path.exists(directory):
|
if not os.path.exists(directory):
|
||||||
os.makedirs(directory)
|
os.makedirs(directory)
|
||||||
|
|
||||||
# Check if the file exists in the local cache
|
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
print(f"Artwork for {game_id} already exists. Skipping download.")
|
print(f"Artwork for {game_id} already exists. Skipping download.")
|
||||||
with open(file_path, 'rb') as image_file:
|
with open(file_path, 'rb') as image_file:
|
||||||
return b64encode(image_file.read()).decode('utf-8')
|
return b64encode(image_file.read()).decode('utf-8')
|
||||||
|
|
||||||
# If the file is in the cache, use that data
|
|
||||||
if cache_key in api_cache:
|
if cache_key in api_cache:
|
||||||
data = api_cache[cache_key]
|
data = api_cache[cache_key]
|
||||||
else:
|
else:
|
||||||
@ -298,13 +295,13 @@ def download_artwork(game_id, art_type, shortcut_id, dimensions=None):
|
|||||||
image_url = artwork['thumb']
|
image_url = artwork['thumb']
|
||||||
print(f"Downloading image from: {image_url}")
|
print(f"Downloading image from: {image_url}")
|
||||||
|
|
||||||
|
# Try both .png and .ico formats
|
||||||
for ext in ['png', 'ico']:
|
for ext in ['png', 'ico']:
|
||||||
try:
|
try:
|
||||||
alt_file_path = file_path.replace('.png', f'.{ext}')
|
alt_file_path = file_path.replace('.png', f'.{ext}')
|
||||||
response = requests.get(image_url, stream=True)
|
response = requests.get(image_url, stream=True)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
with open(alt_file_path, 'wb') as file:
|
with open(alt_file_path, 'wb') as file:
|
||||||
file.write(response.content)
|
file.write(response.content)
|
||||||
@ -358,7 +355,6 @@ def get_file_name(art_type, shortcut_id, dimensions=None):
|
|||||||
else:
|
else:
|
||||||
return f"{shortcut_id}.png"
|
return f"{shortcut_id}.png"
|
||||||
|
|
||||||
|
|
||||||
def is_match(name1, name2):
|
def is_match(name1, name2):
|
||||||
if name1 and name2:
|
if name1 and name2:
|
||||||
return name1.lower() in name2.lower() or name2.lower() in name1.lower()
|
return name1.lower() in name2.lower() or name2.lower() in name1.lower()
|
||||||
@ -366,6 +362,7 @@ def is_match(name1, name2):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Add or update the proton compatibility settings
|
# Add or update the proton compatibility settings
|
||||||
|
|
||||||
def add_compat_tool(app_id, launchoptions):
|
def add_compat_tool(app_id, launchoptions):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user