diff --git a/src/utils/bottles_parser.py b/src/utils/bottles_parser.py index 27bc01c..464075d 100644 --- a/src/utils/bottles_parser.py +++ b/src/utils/bottles_parser.py @@ -90,7 +90,7 @@ def bottles_parser(parent_widget, action): values["last_played"] = 0 if game["thumbnail"]: - values["pixbuf_options"] = save_cover(values, parent_widget, os.path.join(bottles_dir, "bottles", game["bottle"]["path"], "grids", game["thumbnail"].split(":")[1])) + save_cover(values, parent_widget, os.path.join(bottles_dir, "bottles", game["bottle"]["path"], "grids", game["thumbnail"].split(":")[1])) bottles_games[values["game_id"]] = values diff --git a/src/utils/create_details_window.py b/src/utils/create_details_window.py index 6d25cf4..217e652 100644 --- a/src/utils/create_details_window.py +++ b/src/utils/create_details_window.py @@ -175,7 +175,7 @@ def create_details_window(parent_widget, game_id = None): return if pixbuf != None: - values["pixbuf_options"] = save_cover(None, parent_widget, None, pixbuf, game_id) + save_cover(None, parent_widget, None, pixbuf, game_id) values["name"] = final_name values["executable"] = final_executable diff --git a/src/utils/get_cover.py b/src/utils/get_cover.py index 65b8959..6df03c6 100644 --- a/src/utils/get_cover.py +++ b/src/utils/get_cover.py @@ -21,15 +21,12 @@ def get_cover(game, parent_widget): from gi.repository import GdkPixbuf import os - cover_path = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "covers", game["game_id"] + ".dat") + cover_path = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "covers", game["game_id"] + ".png") if os.path.isfile(cover_path) == False: return parent_widget.placeholder_pixbuf - open_file = open((cover_path), "rb") - data = open_file.read() - open_file.close() try: - return GdkPixbuf.Pixbuf.new_from_data(data, *parent_widget.games[game["game_id"]]["pixbuf_options"]) + return GdkPixbuf.Pixbuf.new_from_file(cover_path) except KeyError: return parent_widget.placeholder_pixbuf diff --git a/src/utils/heroic_parser.py b/src/utils/heroic_parser.py index 4b00170..788b211 100644 --- a/src/utils/heroic_parser.py +++ b/src/utils/heroic_parser.py @@ -95,7 +95,7 @@ def heroic_parser(parent_widget, action): image_path = os.path.join(heroic_dir, "images-cache", hashlib.sha256((game["art_square"] + "?h=400&resize=1&w=300").encode()).hexdigest()) if os.path.exists(image_path): - values["pixbuf_options"] = save_cover(values, parent_widget, image_path) + save_cover(values, parent_widget, image_path) heroic_games[values["game_id"]] = values @@ -128,7 +128,7 @@ def heroic_parser(parent_widget, action): image_path = os.path.join(heroic_dir, "images-cache", hashlib.sha256(game["art_square"].encode()).hexdigest()) if os.path.exists(image_path): - values["pixbuf_options"] = save_cover(values, parent_widget, image_path) + save_cover(values, parent_widget, image_path) break values["executable"] = "xdg-open heroic://launch/" + app_name @@ -166,7 +166,7 @@ def heroic_parser(parent_widget, action): image_path = os.path.join(heroic_dir, "images-cache", hashlib.sha256(item["art_square"].encode()).hexdigest()) if os.path.exists(image_path): - values["pixbuf_options"] = save_cover(values, parent_widget, image_path) + save_cover(values, parent_widget, image_path) heroic_games[values["game_id"]] = values diff --git a/src/utils/save_cover.py b/src/utils/save_cover.py index ec52744..63e4b2d 100644 --- a/src/utils/save_cover.py +++ b/src/utils/save_cover.py @@ -28,12 +28,9 @@ def save_cover(game, parent_widget, file_path, pixbuf = None, game_id = None): if game_id == None: game_id = game["game_id"] - cover_path = os.path.join(covers_dir, game_id + ".dat") + cover_path = os.path.join(covers_dir, game_id + ".png") if pixbuf == None: pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(file_path, 400, 600, False) - open_file = open((cover_path), "wb") - open_file.write(bytes(pixbuf.get_pixels())) - open_file.close() - return [pixbuf.get_colorspace(), pixbuf.get_has_alpha(), pixbuf.get_bits_per_sample(), pixbuf.get_width(), pixbuf.get_height(), pixbuf.get_rowstride()] + pixbuf.savev(cover_path, "png") diff --git a/src/utils/steam_parser.py b/src/utils/steam_parser.py index dd102e8..4829708 100644 --- a/src/utils/steam_parser.py +++ b/src/utils/steam_parser.py @@ -97,7 +97,7 @@ def steam_parser(parent_widget, action): values["last_played"] = 0 if os.path.isfile(os.path.join(steam_dir, "appcache", "librarycache", values["appid"] + "_library_600x900.jpg")): - values["pixbuf_options"] = save_cover(values, parent_widget, os.path.join(steam_dir, "appcache", "librarycache", values["appid"] + "_library_600x900.jpg")) + save_cover(values, parent_widget, os.path.join(steam_dir, "appcache", "librarycache", values["appid"] + "_library_600x900.jpg")) steam_games[values["game_id"]] = values