From eb3f9a8b8e77b345f95a994643e8e44a455268be Mon Sep 17 00:00:00 2001 From: kramo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:46:34 +0100 Subject: [PATCH] Use blacklist for non-game items --- src/game.py | 1 + src/utils/steam_parser.py | 24 +++++++++++++----------- src/window.py | 2 ++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/game.py b/src/game.py index 6e8bc0b..c5e5f79 100644 --- a/src/game.py +++ b/src/game.py @@ -48,6 +48,7 @@ class game(Gtk.Box): self.name = data["name"] self.developer = data["developer"] if "developer" in data.keys() else None self.removed = "removed" in data.keys() + self.blacklisted = "blacklisted" in data.keys() self.pixbuf = get_cover(self.game_id, self.parent_widget) diff --git a/src/utils/steam_parser.py b/src/utils/steam_parser.py index e2bc6a6..053f5f1 100644 --- a/src/utils/steam_parser.py +++ b/src/utils/steam_parser.py @@ -140,7 +140,7 @@ def steam_parser(parent_widget, action): basic_data = json.loads(content)[values["appid"]] if not basic_data["success"]: - steam_games.pop(values["game_id"]) + steam_games[values["game_id"]]["blacklisted"] = True else: data = basic_data["data"] steam_games[values["game_id"]]["developer"] = ", ".join( @@ -148,7 +148,7 @@ def steam_parser(parent_widget, action): ) if data["type"] != "game": - steam_games.pop(values["game_id"]) + steam_games[values["game_id"]]["blacklisted"] = True except GLib.GError: pass @@ -157,25 +157,27 @@ def steam_parser(parent_widget, action): if not queue: import_dialog.close() - if not steam_games: - create_dialog( - parent_widget, - _("No Games Found"), - _("No new games were found in the Steam library."), - ) - elif len(steam_games) == 1: + games_no = len( + { + game_id: final_values + for game_id, final_values in steam_games.items() + if "blacklisted" not in final_values.keys() + } + ) + + if games_no == 1: create_dialog( parent_widget, _("Steam Games Imported"), _("Successfully imported 1 game."), ) - elif len(steam_games) > 1: + elif games_no > 1: create_dialog( parent_widget, _("Steam Games Imported"), _("Successfully imported") + " " - + str(len(steam_games)) + + str(games_no) + " " + _("games."), ) diff --git a/src/window.py b/src/window.py index 55e6704..a3d030b 100644 --- a/src/window.py +++ b/src/window.py @@ -144,6 +144,8 @@ class CartridgesWindow(Adw.ApplicationWindow): if entry.removed: continue + if entry.blacklisted: + continue if not self.games[game_id].hidden: self.visible_widgets[game_id] = entry