Fix heroic
This commit is contained in:
@@ -84,7 +84,7 @@ class HeroicSourceIterator(SourceIterator):
|
|||||||
"source": self.source.id,
|
"source": self.source.id,
|
||||||
"added": added_time,
|
"added": added_time,
|
||||||
"name": entry["title"],
|
"name": entry["title"],
|
||||||
"developer": entry["developer"],
|
"developer": entry.get("developer", None),
|
||||||
"game_id": self.source.game_id_format.format(
|
"game_id": self.source.game_id_format.format(
|
||||||
service=service, game_id=app_name
|
service=service, game_id=app_name
|
||||||
),
|
),
|
||||||
@@ -106,14 +106,16 @@ class HeroicSourceIterator(SourceIterator):
|
|||||||
def generator_builder(self) -> SourceIterationResult:
|
def generator_builder(self) -> SourceIterationResult:
|
||||||
"""Generator method producing games from all the Heroic sub-sources"""
|
"""Generator method producing games from all the Heroic sub-sources"""
|
||||||
|
|
||||||
for sub_source in self.sub_sources.values():
|
for sub_source_name, sub_source in self.sub_sources.items():
|
||||||
# Skip disabled sub-sources
|
# Skip disabled sub-sources
|
||||||
if not shared.schema.get_boolean("heroic-import-" + sub_source["service"]):
|
if not shared.schema.get_boolean("heroic-import-" + sub_source["service"]):
|
||||||
continue
|
continue
|
||||||
# Load games from JSON
|
# Load games from JSON
|
||||||
file = self.source.config_location.root.joinpath(*sub_source["path"])
|
file = self.source.config_location.root.joinpath(*sub_source["path"])
|
||||||
try:
|
try:
|
||||||
library = json.load(file.open())["library"]
|
contents = json.load(file.open())
|
||||||
|
key = "library" if sub_source_name == "legendary" else "games"
|
||||||
|
library = contents[key]
|
||||||
except (JSONDecodeError, OSError, KeyError):
|
except (JSONDecodeError, OSError, KeyError):
|
||||||
# Invalid library.json file, skip it
|
# Invalid library.json file, skip it
|
||||||
logging.warning("Couldn't open Heroic file: %s", str(file))
|
logging.warning("Couldn't open Heroic file: %s", str(file))
|
||||||
@@ -124,9 +126,11 @@ class HeroicSourceIterator(SourceIterator):
|
|||||||
for entry in library:
|
for entry in library:
|
||||||
try:
|
try:
|
||||||
result = self.game_from_library_entry(entry, added_time)
|
result = self.game_from_library_entry(entry, added_time)
|
||||||
except KeyError:
|
except KeyError as error:
|
||||||
# Skip invalid games
|
# Skip invalid games
|
||||||
logging.warning("Invalid Heroic game skipped in %s", str(file))
|
logging.warning(
|
||||||
|
"Invalid Heroic game skipped in %s", str(file), exc_info=error
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
yield result
|
yield result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user