Merge pull request #1994 from rommapp/tgdb-handler

Add TheGamesDB handler for platforms
This commit is contained in:
Georges-Antoine Assi
2025-06-18 11:33:19 -04:00
committed by GitHub
9 changed files with 2291 additions and 1 deletions

View File

@@ -90,6 +90,9 @@ HASHEOUS_API_ENABLED: Final = str_to_bool(
os.environ.get("HASHEOUS_API_ENABLED", "false")
)
# THEGAMESDB
TGDB_API_ENABLED: Final = str_to_bool(os.environ.get("TGDB_API_ENABLED", "false"))
# AUTH
ROMM_AUTH_SECRET_KEY: Final = os.environ.get(
"ROMM_AUTH_SECRET_KEY", secrets.token_hex(32)

View File

@@ -15,6 +15,7 @@ from config import (
SCHEDULED_RESCAN_CRON,
SCHEDULED_UPDATE_LAUNCHBOX_METADATA_CRON,
SCHEDULED_UPDATE_SWITCH_TITLEDB_CRON,
TGDB_API_ENABLED,
UPLOAD_TIMEOUT,
)
from endpoints.responses.heartbeat import HeartbeatResponse
@@ -52,7 +53,8 @@ def heartbeat() -> HeartbeatResponse:
or MOBY_API_ENABLED
or RA_API_ENABLED
or LAUNCHBOX_API_ENABLED
or HASHEOUS_API_ENABLED,
or HASHEOUS_API_ENABLED
or TGDB_API_ENABLED,
"IGDB_API_ENABLED": IGDB_API_ENABLED,
"SS_API_ENABLED": SS_API_ENABLED,
"MOBY_API_ENABLED": MOBY_API_ENABLED,
@@ -61,6 +63,7 @@ def heartbeat() -> HeartbeatResponse:
"LAUNCHBOX_API_ENABLED": LAUNCHBOX_API_ENABLED,
"HASHEOUS_API_ENABLED": HASHEOUS_API_ENABLED,
"PLAYMATCH_API_ENABLED": PLAYMATCH_API_ENABLED,
"TGDB_API_ENABLED": TGDB_API_ENABLED,
},
"FILESYSTEM": {
"FS_PLATFORMS": fs_platform_handler.get_platforms(),

View File

@@ -32,6 +32,7 @@ class MetadataSourcesDict(TypedDict):
LAUNCHBOX_API_ENABLED: bool
PLAYMATCH_API_ENABLED: bool
HASHEOUS_API_ENABLED: bool
TGDB_API_ENABLED: bool
class FilesystemDict(TypedDict):

View File

@@ -6,6 +6,7 @@ from .playmatch_handler import PlaymatchHandler
from .ra_handler import RAHandler
from .sgdb_handler import SGDBBaseHandler
from .ss_handler import SSHandler
from .tgdb_handler import TGDBHandler
meta_igdb_handler = IGDBHandler()
meta_moby_handler = MobyGamesHandler()
@@ -15,3 +16,4 @@ meta_ra_handler = RAHandler()
meta_playmatch_handler = PlaymatchHandler()
meta_launchbox_handler = LaunchboxHandler()
meta_hasheous_handler = HasheousHandler()
meta_tgdb_handler = TGDBHandler()

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@ from handler.metadata import (
meta_playmatch_handler,
meta_ra_handler,
meta_ss_handler,
meta_tgdb_handler,
)
from handler.metadata.hasheous_handler import HasheousPlatform, HasheousRom
from handler.metadata.igdb_handler import IGDBPlatform, IGDBRom
@@ -23,6 +24,7 @@ from handler.metadata.moby_handler import MobyGamesPlatform, MobyGamesRom
from handler.metadata.playmatch_handler import PlaymatchProvider, PlaymatchRomMatch
from handler.metadata.ra_handler import RAGameRom, RAGamesPlatform
from handler.metadata.ss_handler import SSPlatform, SSRom
from handler.metadata.tgdb_handler import TGDBPlatform
from logger.formatter import BLUE, LIGHTYELLOW
from logger.formatter import highlight as hl
from logger.logger import log
@@ -51,6 +53,7 @@ class MetadataSource:
RA = "ra" # RetroAchivements
LB = "lb" # Launchbox
HASHEOUS = "hasheous" # Hasheous
TGDB = "tgdb" # TheGamesDB
async def _get_main_platform_igdb_id(platform: Platform):
@@ -155,11 +158,17 @@ async def scan_platform(
if MetadataSource.HASHEOUS in metadata_sources
else HasheousPlatform(hasheous_id=None, slug=platform_attrs["slug"])
)
tgdb_platform = (
meta_tgdb_handler.get_platform(platform_attrs["slug"])
if MetadataSource.TGDB in metadata_sources
else TGDBPlatform(tgdb_id=None, slug=platform_attrs["slug"])
)
platform_attrs["name"] = platform_attrs["slug"].replace("-", " ").title()
platform_attrs.update(
{
**hasheous_platform,
**tgdb_platform,
**launchbox_platform,
**ra_platform,
**moby_platform,
@@ -175,6 +184,7 @@ async def scan_platform(
or platform_attrs["ra_id"]
or platform_attrs["launchbox_id"]
or hasheous_platform["hasheous_id"]
or tgdb_platform["tgdb_id"]
):
log.info(
emoji.emojize(

View File

@@ -33,6 +33,9 @@ LAUNCHBOX_API_ENABLED=
# Hasheous
HASHEOUS_API_ENABLED=
# TheGamesDB
TGDB_API_ENABLED=
# Database config
DB_HOST=127.0.0.1
DB_PORT=3306

View File

@@ -12,5 +12,6 @@ export type MetadataSourcesDict = {
LAUNCHBOX_API_ENABLED: boolean;
PLAYMATCH_API_ENABLED: boolean;
HASHEOUS_API_ENABLED: boolean;
TGDB_API_ENABLED: boolean;
};

View File

@@ -44,6 +44,7 @@ const defaultHeartbeat: Heartbeat = {
LAUNCHBOX_API_ENABLED: false,
PLAYMATCH_API_ENABLED: false,
HASHEOUS_API_ENABLED: false,
TGDB_API_ENABLED: false,
},
FILESYSTEM: {
FS_PLATFORMS: [],