feat: new export.gamelist.media.thumbnail configuration

This commit is contained in:
Vargash
2026-03-31 11:00:49 +02:00
parent 0b8dffa99d
commit 3e072873e1
6 changed files with 56 additions and 5 deletions

View File

@@ -126,6 +126,7 @@ class Config:
SCAN_REGION_PRIORITY: list[str]
SCAN_LANGUAGE_PRIORITY: list[str]
SCAN_MEDIA: list[str]
GAMELIST_THUMBNAIL_MEDIA: str
def __init__(self, **entries):
self.__dict__.update(entries)
@@ -341,6 +342,11 @@ class ConfigManager:
"manual",
],
),
GAMELIST_THUMBNAIL_MEDIA=pydash.get(
self._raw_config,
"export.gamelist.media.thumbnail",
"cover",
),
)
def _get_ejs_controls(self) -> dict[str, EjsControls]:

View File

@@ -75,3 +75,8 @@ emulatorjs:
0:
value: x
value2: BUTTON_2
export:
gamelist:
media:
thumbnail: "box3d"

View File

@@ -54,6 +54,7 @@ def test_config_loader():
assert loader.config.SCAN_ARTWORK_PRIORITY == ["igdb", "ss"]
assert loader.config.SCAN_REGION_PRIORITY == ["jp", "eu", "wor"]
assert loader.config.SCAN_LANGUAGE_PRIORITY == ["jp", "es"]
assert loader.config.GAMELIST_THUMBNAIL_MEDIA == "box3d"
def test_empty_config_loader():
@@ -86,3 +87,4 @@ def test_empty_config_loader():
assert loader.config.EJS_NETPLAY_ICE_SERVERS == []
assert loader.config.EJS_SETTINGS == {}
assert loader.config.EJS_CONTROLS == {}
assert loader.config.GAMELIST_THUMBNAIL_MEDIA == "cover"

View File

@@ -9,6 +9,7 @@ from xml.etree.ElementTree import ( # trunk-ignore(bandit/B405)
from fastapi import Request
from config import FRONTEND_RESOURCES_PATH, YOUTUBE_BASE_URL
from config.config_manager import config_manager as cm
from handler.database import db_platform_handler, db_rom_handler
from handler.filesystem import fs_platform_handler
from logger.logger import log
@@ -51,10 +52,28 @@ class GamelistExporter:
SubElement(game, "desc").text = rom.summary
# Media files
if rom.path_cover_l:
SubElement(game, "thumbnail").text = (
f"{FRONTEND_RESOURCES_PATH}/{rom.path_cover_l}"
)
thumbnail_path: str | None = None
thumbnail_option = cm.config.GAMELIST_THUMBNAIL_MEDIA
if thumbnail_option == "box3d":
if rom.ss_metadata and rom.ss_metadata.get("box3d_path"):
thumbnail_path = f"{FRONTEND_RESOURCES_PATH}/{rom.ss_metadata['box3d_path']}"
elif rom.gamelist_metadata and rom.gamelist_metadata.get("box3d"):
thumbnail_path = rom.gamelist_metadata["box3d"]
elif thumbnail_option == "miximage":
if rom.ss_metadata and rom.ss_metadata.get("miximage_path"):
thumbnail_path = f"{FRONTEND_RESOURCES_PATH}/{rom.ss_metadata['miximage_path']}"
elif rom.gamelist_metadata and rom.gamelist_metadata.get("miximage_path"):
thumbnail_path = f"{FRONTEND_RESOURCES_PATH}/{rom.gamelist_metadata['miximage_path']}"
elif thumbnail_option == "physical":
if rom.ss_metadata and rom.ss_metadata.get("physical_path"):
thumbnail_path = f"{FRONTEND_RESOURCES_PATH}/{rom.ss_metadata['physical_path']}"
elif rom.gamelist_metadata and rom.gamelist_metadata.get("physical_path"):
thumbnail_path = f"{FRONTEND_RESOURCES_PATH}/{rom.gamelist_metadata['physical_path']}"
# "cover" and "box2d" both map to path_cover_l (box2d IS the front cover)
if thumbnail_path is None and rom.path_cover_l:
thumbnail_path = f"{FRONTEND_RESOURCES_PATH}/{rom.path_cover_l}"
if thumbnail_path:
SubElement(game, "thumbnail").text = thumbnail_path
if path_video := rom.path_video:
SubElement(game, "video").text = f"{FRONTEND_RESOURCES_PATH}/{path_video}"

View File

@@ -183,3 +183,11 @@ system:
zx81: zx81
zxspectrum: zxs
versions: {}
export:
gamelist:
media:
# Use the 3D box art as the <thumbnail> tag, preferred by Batocera/RetroBAT
# Falls back to front cover if 3D box art has not been scraped
# Other options: cover (default), box2d, miximage, physical
thumbnail: box3d

View File

@@ -135,6 +135,17 @@
# # Other media assets (might be used in the future)
# - marquee # Custom marquee
# export:
# gamelist:
# media:
# # Media asset to use as the <thumbnail> tag in the exported gamelist.xml
# # cover - front cover art / box2d (default)
# # box2d - same as cover
# # box3d - 3D box art (falls back to cover if not available)
# # miximage - mixed image (falls back to cover if not available)
# # physical - disc/cartridge image (falls back to cover if not available)
# thumbnail: cover
# EmulatorJS per-core options
# emulatorjs:
# debug: true # Available options will be logged to the browser console
@@ -163,4 +174,4 @@
# value2: BUTTON_2 # Mapping for connected controller
# 1: # Player 2
# 2: # Player 3
# 3: # Player 4
# 3: # Player 4