from json import load from os import path from .types import Cover def get_collection(console: str) -> list[Cover]: covers: list[Cover] = [] with open(f"{path.dirname(__file__)}/metadata/{console}.json") as f: games = load(f) for ref in games: game = games[ref] game = game | (games[game["ref"]] if "ref" in game else {}) covers.append( Cover( name=game["name"], logo=game["logo"] if "logo" in game else None, vid=game["vid"] if "vid" in game else None, ref=ref, ) ) return covers