Update Heroic import

This commit is contained in:
kramo
2023-02-03 18:50:40 +01:00
parent 01d1c486c0
commit 79275caa15

View File

@@ -61,45 +61,35 @@ def heroic_parser(parent_widget, action):
# Import Epic games # Import Epic games
if not schema.get_boolean("heroic-import-epic"): if not schema.get_boolean("heroic-import-epic"):
pass pass
elif os.path.exists(os.path.join(heroic_dir, "lib-cache", "installInfo.json")) and os.path.exists( elif os.path.exists(os.path.join(heroic_dir, "lib-cache", "library.json")):
os.path.join(heroic_dir, "lib-cache", "library.json")):
open_file = open(os.path.join(heroic_dir, "lib-cache", "installInfo.json"), "r")
data = open_file.read()
open_file.close()
installInfo = json.loads(data)
open_file = open(os.path.join(heroic_dir, "lib-cache", "library.json"), "r") open_file = open(os.path.join(heroic_dir, "lib-cache", "library.json"), "r")
data = open_file.read() data = open_file.read()
library = json.loads(data) library = json.loads(data)
open_file.close() open_file.close()
for item in installInfo:
if installInfo[item].get("install") is not None:
values = {}
app_name = installInfo[item]["game"]["app_name"]
values["game_id"] = "heroic_epic_" + app_name for game in library["library"]:
if game["is_installed"] == False:
if values["game_id"] in parent_widget.games and "removed" not in parent_widget.games[
values["game_id"]].keys():
continue continue
values["name"] = installInfo[item]["game"]["title"] values = {}
app_name = game["app_name"]
values["game_id"] = "heroic_epic_" + app_name
if values["game_id"] in parent_widget.games and "removed" not in parent_widget.games[values["game_id"]].keys():
continue
values["name"] = game["title"]
values["executable"] = "xdg-open heroic://launch/" + app_name values["executable"] = "xdg-open heroic://launch/" + app_name
values["hidden"] = False values["hidden"] = False
values["source"] = "heroic_epic" values["source"] = "heroic_epic"
values["added"] = current_time values["added"] = current_time
values["last_played"] = 0 values["last_played"] = 0
for game in library["library"]: image_path = os.path.join(heroic_dir, "images-cache", hashlib.sha256((game["art_square"] + "?h=400&resize=1&w=300").encode()).hexdigest())
if game["app_name"] == app_name:
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): if os.path.exists(image_path):
values["pixbuf_options"] = save_cover(values, parent_widget, image_path) values["pixbuf_options"] = save_cover(values, parent_widget, image_path)
break
heroic_games[values["game_id"]] = values heroic_games[values["game_id"]] = values
# Import GOG games # Import GOG games