Adds some fixes found during in-wild testing.

This commit is contained in:
William Hubbard
2022-02-06 05:18:44 +00:00
committed by GitHub
parent 98b7f33096
commit 88e307ff29

View File

@@ -311,7 +311,10 @@ def writeShortcuts(apps, shortcutFile):
i = 1 i = 1
for app in apps: for app in apps:
data.append(0x00) data.append(0x00)
data.append(app.appIndx or i) if app.appIndx > 0 and app.appIndx < 256:
data.append(app.appIndx)
else:
data.append(i)
i += 1 i += 1
data += bytearray([0x00, 0x02]) data += bytearray([0x00, 0x02])
data += bytearray("appid", encoding) data += bytearray("appid", encoding)
@@ -595,8 +598,19 @@ def copyContents(ids):
data = client.get_product_info(apps=fromCodes) data = client.get_product_info(apps=fromCodes)
i = 0 i = 0
for i in range(len(ids)): for i in range(len(ids)):
if not ids[i][0] in data["apps"]:
print("Could not find app ID %s for %s" % (ids[i][0], ids[i][1]), file=sys.stderr)
continue
# Generate the positioning data for logos and such # Generate the positioning data for logos and such
logo = data["apps"][ids[i][0]]["common"]["library_assets"]["logo_position"] assets = data["apps"][ids[i][0]]
if not "common" in assets:
print("Could not find common data for %s from %s" % (ids[i], assets), file=sys.stderr)
continue
if not "library_assets" in assets["common"]:
print("Could not find common data for %s from %s" % (ids[i], assets), file=sys.stderr)
continue
if "logo_position" in assets["common"]["library_assets"]:
logo = assets["common"]["library_assets"]["logo_position"]
logo2 = { logo2 = {
"nVersion": 1, "nVersion": 1,
"logoPosition": { "logoPosition": {
@@ -631,11 +645,16 @@ def copyContents(ids):
] ]
] ]
copyContent(Path("config", "librarycache", str(toCode) + ".json"), json.dumps(logo2), byte=False) copyContent(Path("config", "librarycache", str(toCode) + ".json"), json.dumps(logo2), byte=False)
else:
print("No logo for %s %s" % (ids[i], json.dumps(assets, indent=4)), file=sys.stderr)
# Write the actual shortcut data. # Write the actual shortcut data.
for user in userdata.iterdir(): for user in userdata.iterdir():
shortcutPath = Path(user, "config", "shortcuts.vdf") shortcutPath = Path(user, "config", "shortcuts.vdf")
if shortcutPath.is_file():
shortcutData = parseShortcuts(shortcutPath) shortcutData = parseShortcuts(shortcutPath)
else:
shortcutData = []
toWrite = [] toWrite = []
for app in apps: for app in apps:
toWrite.append(apps[app]) toWrite.append(apps[app])
@@ -643,7 +662,7 @@ def copyContents(ids):
# Add existing apps back to the queue # Add existing apps back to the queue
if app.appId in apps: if app.appId in apps:
eApp = apps[app.appId] eApp = apps[app.appId]
eApp.appIndx = eApp.appIndx or app.appIndx eApp.appIndx = app.appIndx or eApp.appIndx
eApp.name = eApp.name.strip() or app.name.strip() eApp.name = eApp.name.strip() or app.name.strip()
eApp.executable = eApp.executable.strip() or app.executable.strip() eApp.executable = eApp.executable.strip() or app.executable.strip()
eApp.start = eApp.start.strip() or app.start.strip() eApp.start = eApp.start.strip() or app.start.strip()
@@ -710,6 +729,8 @@ if __name__ == "__main__":
ids = [] ids = []
ops = [] ops = []
opArgs = {} opArgs = {}
#for term in sys.argv[1:]:
# print(term)
# Gather the parameters # Gather the parameters
for term in sys.argv[1:]: for term in sys.argv[1:]:
if not term.startswith('-'): if not term.startswith('-'):
@@ -732,7 +753,7 @@ if __name__ == "__main__":
if '=' in term: if '=' in term:
ops.append(term[2:term.index('=')]) ops.append(term[2:term.index('=')])
opArgs[ops[-1]] = term[term.index('=') + 1:] opArgs[ops[-1]] = term[term.index('=') + 1:]
if opArgs[ops[-1]][0] == '"' and opArgs[ops[-1]][-1] == '"' or opArgs[ops[-1]][0] == '\'' and opArgs[ops[-1]][-1] == '\'': if len(opArgs[ops[-1]]) > 0 and (opArgs[ops[-1]][0] == '"' and opArgs[ops[-1]][-1] == '"' or opArgs[ops[-1]][0] == '\'' and opArgs[ops[-1]][-1] == '\''):
# Remove quotation marks used to demark the argument # Remove quotation marks used to demark the argument
opArgs[ops[-1]] = opArgs[ops[-1]][1:-1] opArgs[ops[-1]] = opArgs[ops[-1]][1:-1]
else: else: