Skip to content

Commit

Permalink
Prevent python exceptions on some empty api responses
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkwouter committed Dec 5, 2024
1 parent a2c04d3 commit 2b52192
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion minigalaxy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def get_library(self):
'page': current_page,
}
response = self.__request(url, params=params)
if "totalPages" not in response:
err_msg = "Couldn't load game library"
return games, err_msg
total_pages = response["totalPages"]

for product in response["products"]:
Expand Down Expand Up @@ -121,7 +124,11 @@ def get_owned_products_ids(self):
return
url2 = "https://embed.gog.com/user/data/games"
response2 = self.__request(url2)
return response2["owned"]
if "owned" in response2:
return response2["owned"]

logger.error("Could not load owned games")
return []

# Generate the URL for the login page for GOG
def get_login_url(self) -> str:
Expand Down

0 comments on commit 2b52192

Please sign in to comment.