imLinguin / nile

Unofficial Amazon Games client
GNU General Public License v3.0
306 stars 16 forks source link

JSON error when launching installed game #26

Closed gteachey closed 1 year ago

gteachey commented 1 year ago

I'm able to install Amazon Games, but trying to launch it with nile keeps giving me a JSON error

(nile) suollecram@suoldesk:~/dev/nile$ ./bin/nile launch 2f8ca7a1-f0db-4179-bf06-9227f74fcafa
INFO [CLI]:  Searching for 2f8ca7a1-f0db-4179-bf06-9227f74fcafa
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/suollecram/dev/nile/nile/cli.py", line 238, in <module>
    sys.exit(main())
  File "/home/suollecram/dev/nile/nile/cli.py", line 225, in main
    cli.handle_launch()
  File "/home/suollecram/dev/nile/nile/cli.py", line 184, in handle_launch
    launcher.start(found["path"])
  File "/home/suollecram/dev/nile/nile/utils/launch.py", line 90, in start
    instruction = LaunchInstruction.parse(
  File "/home/suollecram/dev/nile/nile/utils/launch.py", line 22, in parse
    json_data = json.loads(raw_data)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 9 column 3 (char 181)
(nile) suollecram@suoldesk:~/dev/nile$ 

How do I get games to launch with this app?

RParodia commented 1 year ago

It looks to be an issue with loading the game's data found in fuel.json. Unfortunately I don't have that game to try to recreate the error. Please could you go to the game's directory and show what the fuel.json file looks like? It appears to not be valid JSON from the error message.

Edit: I managed to recreate what I believe to be the same error Indiana Jones and the Last Crusade, with fuel.json looking like this:

{
 "SchemaVersion":  "2",
 "PostInstall": [  ],
 "Main": {
   "Command": "Common\\ScummVM\\scummvm.exe",
   "DesktopShortcutIconFile": "Common\\ScummVM\\Indy3.ico",
   "Args": ['-c', 'last-crusade.ini', 'last-crusade']
 }
}

It turns out that the Args field is using single quotes for strings, which isn't valid JSON. If instead of loading with json.loads() we load the data with ast.literal_eval() (which is less strict on exact syntax) then this fixes the issue. However, this has then brought to my attention 2 other issues:

Edit 2: For the Bottles issue, it turns out that:

gteachey commented 1 year ago

Yes that was the problem. The fuel.json had an extra comma in it

{
 "SchemaVersion":  "2",
 "PostInstall": [
   {
       "Command": "dependencies\\oalinst.exe",
       "Args": ["/quiet", "/norestart"],
       "ValidReturns": [ 0, 5100 ]
   }, <<-- BAD COMMA HERE
  ],
 "Main": {
   "Command": "Baldur.exe",
   "Args": []
 }
}

Once I deleted it the game was able to run. Much appreciated!

gteachey commented 1 year ago

Closing my issue now

imLinguin commented 1 year ago

This is some weird kind of JSON though. I'll try to fix the parsing

EDIT: This should be resolved with https://github.com/imLinguin/nile/commit/783327911389972822c85bfc5de59e65c485fdbc

NOTE: there is a new json5 dependency