Repository: lutris/lutris

Issue:
Installer fails for gog games with a provider but no gogid
### Bug description

When you run the installer, it freezes just before the file selection screen.

![image](https://user-images.githubusercontent.com/97908325/153111251-b5eea9dc-8756-4e46-b401-93c98250da20.png)

Might be related to https://github.com/lutris/lutris/issues/4016. Different cause of the error, but maybe triggering the same UI problem.

### How to Reproduce

Steps to reproduce the behavior:
1. Log in to GOG through Lutris.
2. Go to 'https://lutris.net/games/140/
 -   It can be any game that **has a gog provider game** associated, but **does not have a `gogid`**
      ![image](https://user-images.githubusercontent.com/97908325/153111345-8e3bf8b6-7308-41b5-ac0a-c69e1a5d68f1.png)
2. Click on 'Install' for the gog installer
3. In the lutris install dialog which pops up, click 'install' twice (to confirm the installer, then to confirm the installation path)


### Expected behavior

Proceed to the file screen, where I can choose between automatic download or manually providing the file.

### Log output

```shell
$ lutris -d
2022-02-08 21:30:58,446: Starting Lutris 0.5.9.1
2022-02-08 21:30:58,500: No cores found
2022-02-08 21:30:59,315: Failed to read content length on response from https://api.github.com/repos/lutris/dxvk/releases
2022-02-08 21:30:59,769: Startup complete
INFO     2022-02-08 21:30:59,772 [startup.check_driver:61]:Running Intel Mesa driver 21.3.5 on Mesa Intel(R) UHD Graphics 620 (KBL GT2) (0x5917)
INFO     2022-02-08 21:30:59,773 [startup.check_driver:73]:GPU: 8086:5917 1043:1D30 (i915 drivers)
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0
DEBUG    2022-02-08 21:31:00,507 [lutriswindow.update_store:451]:Showing 325 games
2022-02-08 21:31:07,523: Running Intel Mesa driver 21.3.5 on Mesa Intel(R) UHD Graphics 620 (KBL GT2) (0x5917)
2022-02-08 21:31:07,523: GPU: 8086:5917 1043:1D30 (i915 drivers)
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0
2022-02-08 21:31:07,545: Fetching installer https://lutris.net/api/installers/140-gogcom
2022-02-08 21:31:07,545: GET https://lutris.net/api/installers/140-gogcom
2022-02-08 21:31:07,865: Showing window <class 'lutris.gui.installerwindow.InstallerWindow'>140
2022-02-08 21:31:10,058: Retrieving current resolution
2022-02-08 21:31:20,036: GET https://embed.gog.com/userData.json
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/lutris/gui/installerwindow.py", line 294, in on_runners_ready
    self.interpreter.installer.prepare_game_files()
  File "/usr/lib/python3.10/site-packages/lutris/installer/installer.py", line 149, in prepare_game_files
    installer_files = self.service.get_installer_files(self, installer_file_id)
  File "/usr/lib/python3.10/site-packages/lutris/services/gog.py", line 393, in get_installer_files
    downloads = self.get_downloads(installer.service_appid)
  File "/usr/lib/python3.10/site-packages/lutris/services/gog.py", line 306, in get_downloads
    gog_data = self.get_game_details(gogid)
  File "/usr/lib/python3.10/site-packages/lutris/services/gog.py", line 282, in get_game_details
    raise ValueError("Missing product ID")
ValueError: Missing product ID
2022-02-08 21:31:20,493: Creating destination path /home/smichel/Data/Games/140
^C
```


### System Information

```shell
[System]
OS:              Fedora Linux 35 
Arch:            x86_64
Kernel:          5.15.18-200.fc35.x86_64
Desktop:         GNOME
Display Server:  wayland

[CPU]
Vendor:          GenuineIntel
Model:           Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Physical cores:  4
Logical cores:   8

[Memory]
RAM:             7.6 GB
Swap:            15.4 GB

[Graphics]
Vendor:          Intel
OpenGL Renderer: Mesa Intel(R) UHD Graphics 620 (KBL GT2)
OpenGL Version:  4.6 (Compatibility Profile) Mesa 21.3.5
OpenGL Core:     4.6 (Core Profile) Mesa 21.3.5
OpenGL ES:       OpenGL ES 3.2 Mesa 21.3.5
Vulkan:          Supported
```


### Media (optional)

_No response_

### Checklist:

- [X] I'm not asking for support with a game or the wine runner.
- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.


Discussion:

Resolving patch:
diff --git a/lutris/installer/installer.py b/lutris/installer/installer.py
--- a/lutris/installer/installer.py
+++ b/lutris/installer/installer.py
@@ -164,7 +164,10 @@ def prepare_game_files(self, patch_version=None):
             self.files.append(installer_file)
         if not installer_files:
             # Failed to get the service game, put back a user provided file
-            self.files.insert(0, "N/A: Provider installer file")
+            self.files.insert(0, InstallerFile(self.game_slug, installer_file_id, {
+                "url": "N/A: Provider installer file",
+                "filename": ""
+            }))
 
     def _substitute_config(self, script_config):
         """Substitute values such as $GAMEDIR in a config dict."""
diff --git a/lutris/services/gog.py b/lutris/services/gog.py
--- a/lutris/services/gog.py
+++ b/lutris/services/gog.py
@@ -316,10 +316,13 @@ def get_download_info(self, downlink):
 
     def get_downloads(self, gogid):
         """Return all available downloads for a GOG ID"""
+        if not gogid:
+            logger.warning("Unable to get GOG data because no GOG ID is available")
+            return {}
         gog_data = self.get_game_details(gogid)
         if not gog_data:
             logger.warning("Unable to get GOG data for game %s", gogid)
-            return []
+            return {}
         return gog_data["downloads"]
 
     def get_extras(self, gogid):
@@ -337,7 +340,7 @@ def get_extras(self, gogid):
     def get_installers(self, downloads, runner, language="en"):
         """Return available installers for a GOG game"""
         # Filter out Mac installers
-        gog_installers = [installer for installer in downloads["installers"] if installer["os"] != "mac"]
+        gog_installers = [installer for installer in downloads.get("installers", []) if installer["os"] != "mac"]
         available_platforms = {installer["os"] for installer in gog_installers}
         # If it's a Linux game, also filter out Windows games
         if "linux" in available_platforms:


Test patch: