Finish Dolphin importer, fix cache reader bug

This commit is contained in:
Rilic
2023-07-23 22:22:18 +01:00
parent 9618fb7fff
commit 5708f48db8
2 changed files with 20 additions and 18 deletions

View File

@@ -17,6 +17,7 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path
from time import time from time import time
from src import shared from src import shared
@@ -36,23 +37,25 @@ class DolphinIterator(SourceIterator):
games_data = cache_reader.get_games() games_data = cache_reader.get_games()
for game_data in games_data: for game_data in games_data:
print(game_data["file_name"])
# Build game # Build game
game = Game(values)
values = { values = {
"source": self.source.id, "source": self.source.id,
"added": added_time, "added": added_time,
# "name": item["label"], "name": Path(game_data["file_name"]).stem,
# "game_id": self.source.game_id_format.format(game_id=game_id), "game_id": self.source.game_id_format.format(
# "executable": self.source.executable_format.format( game_id=game_data["game_id"]
# rom_path=item["path"], ),
# core_path=core_path, "executable": self.source.executable_format.format(
# ), rom_path=game_data["file_path"],
),
} }
game = Game(values) game = Game(values)
additional_data = {}
image_path = Path(
self.source.cache_location["covers"] / (game_data["game_id"] + ".png")
)
additional_data = {"local_image_path": image_path}
yield (game, additional_data) yield (game, additional_data)
@@ -68,15 +71,13 @@ class DolphinSource(Source):
shared.flatpak_dir / "org.DolphinEmu.dolphin-emu" / "cache" / "dolphin-emu", shared.flatpak_dir / "org.DolphinEmu.dolphin-emu" / "cache" / "dolphin-emu",
shared.home / ".cache" / "dolphin-emu", shared.home / ".cache" / "dolphin-emu",
), ),
paths={ paths={"cache_file": (False, "gamelist.cache"), "covers": (True, "GameCovers")},
"cache_file": (False, "gamelist.cache"),
},
) )
@property @property
def executable_format(self): def executable_format(self):
self.config_location.resolve() self.cache_location.resolve()
is_flatpak = self.data_location.root.is_relative_to(shared.flatpak_dir) is_flatpak = self.cache_location.root.is_relative_to(shared.flatpak_dir)
base = "flatpak run org.DolphinEmu.dolphin-emu" if is_flatpak else "dolphin-emu" base = "flatpak run org.DolphinEmu.dolphin-emu" if is_flatpak else "dolphin-emu"
args = '-e "{rom_path}"' args = '-e "{rom_path}"'
return f"{base} {args}" return f"{base} {args}"

View File

@@ -1,10 +1,11 @@
"""Reads the Dolphin game database, stored in a binary format""" """Reads the Dolphin game database, stored in a binary format"""
# Copyright 2022 strycore - Lutris # Copyright 2022-2023 strycore - Lutris
# Copyright 2023 Rilic
import logging import logging
from pathlib import Path from pathlib import Path
SUPPORTED_CACHE_VERSION = 20 SUPPORTED_CACHE_VERSION = 24
def get_hex_string(string): def get_hex_string(string):
@@ -29,7 +30,7 @@ class DolphinCacheReader:
"file_name": "s", "file_name": "s",
"file_size": 8, "file_size": 8,
"volume_size": 8, "volume_size": 8,
"volume_size_is_accurate": 1, "volume_size_type": 4,
"is_datel_disc": 1, "is_datel_disc": 1,
"is_nkit": 1, "is_nkit": 1,
"short_names": "a", "short_names": "a",