Files
romm/backend/tools/generate_supported_platforms.py
Spinnich 60703be09c chore(platforms): split arcade aliases into per-emulator-family slugs (#5273)
* feat(platforms): split arcade aliases into per-emulator-family slugs

Give MAME, AdvanceMAME, FBNeo, FBA, Daphne, Singe and the arcade boards
that need their own emulator (NAOMI/NAOMI 2/NAOMI GD-ROM, Model 2/3,
Hikaru, Triforce, Lindbergh, Namco System 246/3xx, Gaelco, ...) their own
slugs with verified provider IDs. Providers without a dedicated entry fall
back to their Arcade platform via arcade_fallbacks(). MAME-only boards
(CPS1-3, System 16/32, Model 1, Namco 22) stay aliases of arcade.

Refs #5272

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(platforms): code-review pass on arcade slugs

- Retry IGDB on unmatched scans for every platform IGDB resolves, not
  just slugs in IGDB_PLATFORM_LIST.
- Resolve config binding/version values through the alias table, so a
  binding to a retired slug (cps2, model1, ...) still lands on a platform.
- Alias the Batocera `typex` folder to type-x.
- Build provider id->slug reverse maps before merging Arcade fallbacks.
- Share one MAME title lookup between base_handler and libretro.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(platforms): simplify pass on arcade slugs

- Alias the three RomM-keyed IGDB versions inside IGDB_PLATFORM_VERSIONS,
  dropping IGDB_VERSION_SLUGS and _version_slug.
- Derive EmulatorJS arcade entries from ARCADE_SET_PLATFORMS.
- Remove the unused provider id->slug reverse maps, so the Arcade
  fallback merge no longer has an ordering constraint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(platforms): humanizer pass on arcade slug comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(platforms): settle arcade slug review decisions

- Migration 0154 moves platforms still on a retired MAME-only board slug
  (cps1-3, model1, system16, system32, system-32) to arcade, so no row
  carries a slug the enum no longer has.
- MAME shortname expansion keys off the RomM slug via
  MAME_SHORTNAME_PLATFORMS instead of per-provider arcade ids, so Daphne,
  Singe, Type X and Lindbergh sets are no longer read as MAME sets. Neo Geo
  now expands at ScreenScraper too, as it already did at IGDB and Moby.
- fba offers fbneo before the FinalBurn Alpha CPS cores.
- AdvanceMAME leaves the WebRcade feed; EmulatorJS and WebRcade share
  PLAYABLE_ARCADE_SET_PLATFORMS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(platforms): code-review pass (xhigh) on arcade slugs

Verify arcade-board BIOS files against the known list's arcade entries,
and make migration 0154 match retired slugs case-insensitively.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(platforms): simplify pass on arcade slugs

Apply IGDB family overrides once in get_platform instead of on each
return path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(platforms): use a slug with no shipped icon

singe now ships an icon, so the no-icon prefetch test needs a slug that never will.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(platforms): add a teknoparrot arcade slug

TeknoParrot runs PC-based arcade boards outside the MAME/FinalBurn family,
so its folder gets its own platform (RetroBat and ES-DE both use
`teknoparrot`). Providers fall back to their Arcade entry, MAME shortname
expansion skips it, and it gets a placeholder icon copied from `arcade`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(platforms): give each arcade-family icon its own marquee title

Redraws the ARCADE marquee on the copied cabinet icons with each
platform's name, in the Bungee typeface with the original inline and
extrusion styling. Sega boards use Sega blue, Namco systems Namco red,
and Type X Taito blue; the rest keep the original amber.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(platforms): code-review pass (xhigh) on arcade slugs

Neo Geo BIOS lives under arcade in the known BIOS list, so map
neogeoaes and neogeomvs there too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(platforms): simplify pass on arcade slug tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
2026-10-28 19:53:06 -04:00

134 lines
5.9 KiB
Python

#!/usr/bin/env python3
"""Print the supported-platforms table (Markdown) for the docs.
Walks every UniversalPlatformSlug, collects each metadata provider's
platform mapping, and emits a Markdown table (with provider link icons) to
stdout for pasting into the documentation.
Run from the backend directory:
uv run python -m tools.generate_supported_platforms
"""
from typing import TypedDict
from urllib.parse import quote
from handler.metadata import (
meta_flashpoint_handler,
meta_hasheous_handler,
meta_hltb_handler,
meta_igdb_handler,
meta_launchbox_handler,
meta_libretro_handler,
meta_moby_handler,
meta_ra_handler,
meta_ss_handler,
)
from handler.metadata.platform_names import resolve_platform_name
from utils.platform_slugs import UniversalPlatformSlug
class SupportedPlatform(TypedDict):
name: str
folder: str
igdb_slug: str | None
moby_slug: str | None
ss_id: int | None
launchbox_id: int | None
hasheous_id: int | None
ra_id: int | None
flashpoint_id: int | None
hltb_slug: str | None
libretro_slug: str | None
if __name__ == "__main__":
supported_platforms: dict[str, SupportedPlatform] = {}
for upl in UniversalPlatformSlug:
slug_lower = upl.value.lower()
igdb_platform = meta_igdb_handler.get_platform(slug_lower)
moby_platform = meta_moby_handler.get_platform(slug_lower)
ss_platform = meta_ss_handler.get_platform(slug_lower)
launchbox_platform = meta_launchbox_handler.get_platform(slug_lower)
hasheous_platform = meta_hasheous_handler.get_platform(slug_lower)
ra_platform = meta_ra_handler.get_platform(slug_lower)
flashpoint_platform = meta_flashpoint_handler.get_platform(slug_lower)
hltb_platform = meta_hltb_handler.get_platform(slug_lower)
libretro_platform = meta_libretro_handler.get_platform(slug_lower)
supported_platforms[slug_lower] = {
"name": resolve_platform_name(slug_lower),
"folder": slug_lower,
"igdb_slug": igdb_platform.get("igdb_slug", None),
"moby_slug": moby_platform.get("moby_slug", None),
"ss_id": ss_platform["ss_id"],
"launchbox_id": launchbox_platform["launchbox_id"],
"hasheous_id": hasheous_platform["hasheous_id"],
"ra_id": ra_platform["ra_id"],
"flashpoint_id": flashpoint_platform["flashpoint_id"],
"hltb_slug": hltb_platform.get("hltb_slug", None),
"libretro_slug": libretro_platform.get("libretro_slug", None),
}
# Sort platforms by name field
supported_platforms = dict(
sorted(supported_platforms.items(), key=lambda item: item[1]["name"].lower())
)
print("""|Platform Name|Folder Name|Metadata Providers|
|---|---|---|""")
for platform in supported_platforms.values():
print(
f'| {platform["name"]} |',
f'`{platform["folder"]}` |',
(
f'<a href="https://www.igdb.com/platforms/{platform["igdb_slug"]}" target="_blank" rel="noopener noreferrer"><img alt="igdb logo" src="../../resources/metadata_providers/igdb.png" height="24px" width="24px"></a>'
if platform["igdb_slug"]
else ""
),
(
f'<a href="https://www.screenscraper.fr/systemeinfos.php?plateforme={platform["ss_id"]}" target="_blank" rel="noopener noreferrer"><img alt="screenscraper logo" src="../../resources/metadata_providers/ss.png" height="24px" width="24px"></a>'
if platform["ss_id"]
else ""
),
(
f'<a href="https://www.mobygames.com/platform/{platform["moby_slug"]}" target="_blank" rel="noopener noreferrer"><img alt="mobygames logo" src="../../resources/metadata_providers/moby.png" height="24px" width="24px"></a>'
if platform["moby_slug"]
else ""
),
(
f'<a href="https://gamesdb.launchbox-app.com/platforms/games/{platform["launchbox_id"]}" target="_blank" rel="noopener noreferrer"><img alt="launchbox logo" src="../../resources/metadata_providers/launchbox.png" height="24px" width="24px"></a>'
if platform["launchbox_id"]
else ""
),
(
f'<a href="https://hasheous.org/index.html?page=dataobjectdetail&type=platform&id={platform["hasheous_id"]}" target="_blank" rel="noopener noreferrer"><img alt="hasheous logo" src="../../resources/metadata_providers/hasheous.png" height="24px" width="24px"></a>'
if platform["hasheous_id"]
else ""
),
(
f'<a href="https://retroachievements.org/system/{platform["ra_id"]}/games" target="_blank" rel="noopener noreferrer"><img alt="retroachivements logo" src="../../resources/metadata_providers/ra.png" height="24px" width="24px"></a>'
if platform["ra_id"]
else ""
),
(
f'<a href="https://flashpoint-project.org/platforms/{platform["flashpoint_id"]}" target="_blank" rel="noopener noreferrer"><img alt="flashpoint logo" src="../../resources/metadata_providers/flashpoint.png" height="24px" width="24px"></a>'
if platform["flashpoint_id"]
else ""
),
(
'<img alt="howlongtobeat logo" src="../../resources/metadata_providers/hltb.png" height="24px" width="24px">'
if platform["hltb_slug"]
else ""
),
(
f'<a href="https://thumbnails.libretro.com/{quote(platform["libretro_slug"], safe="")}" target="_blank" rel="noopener noreferrer"><img alt="libretro logo" src="../../resources/metadata_providers/libretro.png" height="24px" width="24px"></a>'
if platform["libretro_slug"]
else ""
),
" |",
)