Fix import from Heroic if no Epic games
This commit is contained in:
@@ -112,44 +112,47 @@ def heroic_parser(parent_widget, action):
|
|||||||
open_file.close()
|
open_file.close()
|
||||||
library = json.loads(data)
|
library = json.loads(data)
|
||||||
|
|
||||||
for game in library["library"]:
|
try:
|
||||||
if not game["is_installed"]:
|
for game in library["library"]:
|
||||||
continue
|
if not game["is_installed"]:
|
||||||
|
continue
|
||||||
|
|
||||||
values = {}
|
values = {}
|
||||||
|
|
||||||
app_name = game["app_name"]
|
app_name = game["app_name"]
|
||||||
values["game_id"] = "heroic_epic_" + app_name
|
values["game_id"] = "heroic_epic_" + app_name
|
||||||
|
|
||||||
if (
|
if (
|
||||||
values["game_id"] in parent_widget.games
|
values["game_id"] in parent_widget.games
|
||||||
and not parent_widget.games[values["game_id"]].removed
|
and not parent_widget.games[values["game_id"]].removed
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
values["name"] = game["title"]
|
values["name"] = game["title"]
|
||||||
values["developer"] = game["developer"]
|
values["developer"] = game["developer"]
|
||||||
values["executable"] = (
|
values["executable"] = (
|
||||||
"start heroic://launch/" + app_name
|
"start heroic://launch/" + app_name
|
||||||
if os.name == "nt"
|
if os.name == "nt"
|
||||||
else "xdg-open heroic://launch/" + app_name
|
else "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
|
||||||
|
|
||||||
image_path = os.path.join(
|
image_path = os.path.join(
|
||||||
heroic_dir,
|
heroic_dir,
|
||||||
"images-cache",
|
"images-cache",
|
||||||
hashlib.sha256(
|
hashlib.sha256(
|
||||||
(game["art_square"] + "?h=400&resize=1&w=300").encode()
|
(game["art_square"] + "?h=400&resize=1&w=300").encode()
|
||||||
).hexdigest(),
|
).hexdigest(),
|
||||||
)
|
)
|
||||||
if os.path.exists(image_path):
|
if os.path.exists(image_path):
|
||||||
save_cover(values, parent_widget, image_path)
|
save_cover(values, parent_widget, image_path)
|
||||||
|
|
||||||
heroic_games[values["game_id"]] = values
|
heroic_games[values["game_id"]] = values
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Import GOG games
|
# Import GOG games
|
||||||
if not schema.get_boolean("heroic-import-gog"):
|
if not schema.get_boolean("heroic-import-gog"):
|
||||||
|
|||||||
Reference in New Issue
Block a user