Files
romm/backend/handler/metadata/launchbox_handler/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

258 lines
12 KiB
Python

from typing import TypedDict
from utils.arcade_platforms import arcade_fallbacks
from utils.platform_slugs import UniversalPlatformSlug as UPS
from utils.platform_slugs import fill_duplicate_slugs
from .types import LaunchboxPlatform
class SlugToLaunchboxId(TypedDict):
id: int
name: str
LAUNCHBOX_PLATFORM_LIST: dict[UPS, SlugToLaunchboxId] = {
UPS.VECTOR_06C: {"id": 199, "name": "Vector-06C"},
UPS._3DO: {"id": 1, "name": "3DO Interactive Multiplayer"},
UPS.N3DS: {"id": 24, "name": "Nintendo 3DS"},
UPS.N64DD: {"id": 194, "name": "Nintendo 64DD"},
UPS.ACORN_ARCHIMEDES: {"id": 74, "name": "Acorn Archimedes"},
UPS.ACORN_ELECTRON: {"id": 65, "name": "Acorn Electron"},
UPS.ACPC: {"id": 3, "name": "Amstrad CPC"},
UPS.ACTION_MAX: {"id": 154, "name": "WoW Action Max"},
UPS.ADVENTURE_VISION: {
"id": 67,
"name": "Entex Adventure Vision",
},
UPS.ALICE_3290: {"id": 189, "name": "Matra and Hachette Alice"},
UPS.AMIGA: {"id": 2, "name": "Commodore Amiga"},
UPS.AMIGA_CD32: {"id": 119, "name": "Commodore Amiga CD32"},
UPS.AMSTRAD_GX4000: {"id": 109, "name": "Amstrad GX4000"},
UPS.ANDROID: {"id": 4, "name": "Android"},
UPS.APF: {"id": 68, "name": "APF Imagination Machine"},
UPS.APPLE_IIGS: {"id": 112, "name": "Apple IIGS"},
UPS.APPLEII: {"id": 110, "name": "Apple II"},
UPS.ARCADE: {"id": 5, "name": "Arcade"},
UPS.ATOMISWAVE: {"id": 98, "name": "Sammy Atomiswave"},
UPS.NAOMI: {"id": 99, "name": "Sega Naomi"},
UPS.NAOMI2: {"id": 100, "name": "Sega Naomi 2"},
UPS.TRIFORCE: {"id": 207, "name": "Sega Triforce"},
UPS.ARCADIA_2001: {"id": 79, "name": "Emerson Arcadia 2001"},
UPS.ASTROCADE: {"id": 77, "name": "Bally Astrocade"},
UPS.ATARI_JAGUAR_CD: {"id": 10, "name": "Atari Jaguar CD"},
UPS.ATARI_ST: {"id": 76, "name": "Atari ST"},
UPS.ATARI_XEGS: {"id": 12, "name": "Atari XEGS"},
UPS.ATARI2600: {"id": 6, "name": "Atari 2600"},
UPS.ATARI5200: {"id": 7, "name": "Atari 5200"},
UPS.ATARI7800: {"id": 8, "name": "Atari 7800"},
UPS.ATARI800: {"id": 102, "name": "Atari 800"},
UPS.ATMOS: {"id": 64, "name": "Oric Atmos"},
UPS.ATOM: {"id": 107, "name": "Acorn Atom"},
UPS.BBCMICRO: {"id": 59, "name": "BBC Microcomputer System"},
UPS.BK: {"id": 131, "name": "Elektronika BK"},
UPS.BK_01: {"id": 175, "name": "Apogee BK-01"},
UPS.BROWSER: {"id": 85, "name": "Web Browser"},
UPS.C_PLUS_4: {"id": 121, "name": "Commodore Plus 4"},
UPS.C128: {"id": 118, "name": "Commodore 128"},
UPS.C64: {"id": 14, "name": "Commodore 64"},
UPS.CAMPUTERS_LYNX: {"id": 61, "name": "Camputers Lynx"},
UPS.CASIO_LOOPY: {"id": 114, "name": "Casio Loopy"},
UPS.CASIO_PV_1000: {"id": 115, "name": "Casio PV-1000"},
UPS.COLECOADAM: {"id": 117, "name": "Coleco ADAM"},
UPS.COLECOVISION: {"id": 13, "name": "ColecoVision"},
UPS.COLOUR_GENIE: {"id": 73, "name": "EACA EG2000 Colour Genie"},
UPS.COMMODORE_CDTV: {"id": 120, "name": "Commodore CDTV"},
UPS.CPET: {"id": 180, "name": "Commodore PET"},
UPS.CREATIVISION: {"id": 152, "name": "VTech CreatiVision"},
UPS.DC: {"id": 40, "name": "Sega Dreamcast"},
UPS.DOS: {"id": 83, "name": "MS-DOS"},
UPS.DRAGON_32_SLASH_64: {"id": 66, "name": "Dragon 32/64"},
UPS.ENTERPRISE: {"id": 72, "name": "Enterprise"},
UPS.EPOCH_GAME_POCKET_COMPUTER: {
"id": 132,
"name": "Epoch Game Pocket Computer",
},
UPS.EPOCH_SUPER_CASSETTE_VISION: {
"id": 81,
"name": "Epoch Super Cassette Vision",
},
UPS.EXELVISION: {"id": 183, "name": "Exelvision EXL 100"},
UPS.EXIDY_SORCERER: {"id": 184, "name": "Exidy Sorcerer"},
UPS.FAIRCHILD_CHANNEL_F: {
"id": 58,
"name": "Fairchild Channel F",
},
UPS.FAMICOM: {"id": 27, "name": "Nintendo Entertainment System"},
UPS.FDS: {"id": 157, "name": "Nintendo Famicom Disk System"},
UPS.FM_7: {"id": 186, "name": "Fujitsu FM-7"},
UPS.FM_TOWNS: {"id": 124, "name": "Fujitsu FM Towns Marty"},
UPS.G_AND_W: {"id": 166, "name": "Nintendo Game & Watch"},
UPS.GAME_DOT_COM: {"id": 63, "name": "Tiger Game.com"},
UPS.GAME_WAVE: {"id": 216, "name": "GameWave"},
UPS.GAMEGEAR: {"id": 41, "name": "Sega Game Gear"},
UPS.GB: {"id": 28, "name": "Nintendo Game Boy"},
UPS.GBA: {"id": 29, "name": "Nintendo Game Boy Advance"},
UPS.GBC: {"id": 30, "name": "Nintendo Game Boy Color"},
UPS.GENESIS: {"id": 42, "name": "Sega Genesis"},
UPS.GP32: {"id": 135, "name": "GamePark GP32"},
UPS.HARTUNG: {"id": 136, "name": "Hartung Game Master"},
UPS.HIKARU: {"id": 208, "name": "Sega Hikaru"},
UPS.HRX: {"id": 187, "name": "Hector HRX"},
UPS.HYPERSCAN: {"id": 171, "name": "Mattel HyperScan"},
UPS.INTELLIVISION: {"id": 15, "name": "Mattel Intellivision"},
UPS.IOS: {"id": 16, "name": "Apple iOS"},
UPS.JAGUAR: {"id": 9, "name": "Atari Jaguar"},
UPS.JUPITER_ACE: {"id": 70, "name": "Jupiter Ace"},
UPS.LINUX: {"id": 218, "name": "Linux"},
UPS.LYNX: {"id": 11, "name": "Atari Lynx"},
UPS.MAC: {"id": 17, "name": "Apple Mac OS"},
UPS.AQUARIUS: {"id": 69, "name": "Mattel Aquarius"},
UPS.MEGA_DUCK_SLASH_COUGAR_BOY: {"id": 127, "name": "Mega Duck"},
UPS.MODEL2: {"id": 88, "name": "Sega Model 2"},
UPS.MODEL3: {"id": 94, "name": "Sega Model 3"},
UPS.MSX: {"id": 82, "name": "Microsoft MSX"},
UPS.MSX2: {"id": 190, "name": "Microsoft MSX2"},
UPS.MSX2PLUS: {"id": 191, "name": "Microsoft MSX2+"},
UPS.MTX512: {"id": 60, "name": "Memotech MTX512"},
UPS.MUGEN: {"id": 138, "name": "MUGEN"},
UPS.MULTIVISION: {"id": 197, "name": "Othello Multivision"},
UPS.N64: {"id": 25, "name": "Nintendo 64"},
UPS.NDS: {"id": 26, "name": "Nintendo DS"},
UPS.NEO_GEO_CD: {"id": 167, "name": "SNK Neo Geo CD"},
UPS.NEO_GEO_POCKET: {"id": 21, "name": "SNK Neo Geo Pocket"},
UPS.NEO_GEO_POCKET_COLOR: {
"id": 22,
"name": "SNK Neo Geo Pocket Color",
},
UPS.NEOGEOAES: {"id": 23, "name": "SNK Neo Geo AES"},
UPS.NEOGEOMVS: {"id": 210, "name": "SNK Neo Geo MVS"},
UPS.NES: {"id": 27, "name": "Nintendo Entertainment System"},
UPS.NGAGE: {"id": 213, "name": "Nokia N-Gage"},
UPS.NGC: {"id": 31, "name": "Nintendo GameCube"},
UPS.NUON: {"id": 126, "name": "Nuon"},
UPS.ODYSSEY: {"id": 78, "name": "Magnavox Odyssey"},
UPS.ODYSSEY_2: {
"id": 57,
"name": "Magnavox Odyssey 2",
},
UPS.OPENBOR: {"id": 139, "name": "OpenBOR"},
UPS.OUYA: {"id": 35, "name": "Ouya"},
UPS.PC_8800_SERIES: {"id": 192, "name": "NEC PC-8801"},
UPS.PC_9800_SERIES: {"id": 193, "name": "NEC PC-9801"},
UPS.PC_FX: {"id": 161, "name": "NEC PC-FX"},
UPS.PEGASUS: {"id": 174, "name": "Aamber Pegasus"},
UPS.PHILIPS_CD_I: {"id": 37, "name": "Philips CD-i"},
UPS.PHILIPS_VG_5000: {"id": 140, "name": "Philips VG 5000"},
UPS.PICO: {"id": 220, "name": "PICO-8"},
UPS.PINBALL: {"id": 151, "name": "Pinball"},
UPS.POCKETSTATION: {"id": 203, "name": "Sony PocketStation"},
UPS.POKEMON_MINI: {"id": 195, "name": "Nintendo Pokemon Mini"},
UPS.PS2: {"id": 48, "name": "Sony Playstation 2"},
UPS.PS3: {"id": 49, "name": "Sony Playstation 3"},
UPS.PS4: {"id": 50, "name": "Sony Playstation 4"},
UPS.PS5: {"id": 219, "name": "Sony Playstation 5"},
UPS.PSP: {"id": 52, "name": "Sony PSP"},
UPS.PSP_MINIS: {"id": 202, "name": "Sony PSP Minis"},
UPS.PSVITA: {"id": 51, "name": "Sony Playstation Vita"},
UPS.PSX: {"id": 47, "name": "Sony Playstation"},
UPS.RCA_STUDIO_II: {"id": 142, "name": "RCA Studio II"},
UPS.SAM_COUPE: {"id": 71, "name": "SAM Coupé"},
UPS.SATELLAVIEW: {"id": 168, "name": "Nintendo Satellaview"},
UPS.SATURN: {"id": 45, "name": "Sega Saturn"},
UPS.SC3000: {"id": 145, "name": "Sega SC-3000"},
UPS.SCUMMVM: {"id": 143, "name": "ScummVM"},
UPS.SEGA_PICO: {"id": 105, "name": "Sega Pico"},
UPS.SEGA32: {"id": 38, "name": "Sega 32X"},
UPS.SEGACD: {"id": 39, "name": "Sega CD"},
UPS.SEGACD32: {"id": 173, "name": "Sega CD 32X"},
UPS.SERIES_X_S: {"id": 222, "name": "Microsoft Xbox Series X/S"},
UPS.SFAM: {"id": 53, "name": "Super Nintendo Entertainment System"},
UPS.SG1000: {"id": 80, "name": "Sega SG-1000"},
UPS.SHARP_MZ_80B20002500: {"id": 205, "name": "Sharp MZ-2500"},
UPS.SHARP_X68000: {"id": 128, "name": "Sharp X68000"},
UPS.SMS: {"id": 43, "name": "Sega Master System"},
UPS.SNES: {
"id": 53,
"name": "Super Nintendo Entertainment System",
},
UPS.SOCRATES: {"id": 198, "name": "VTech Socrates"},
UPS.SORD_M5: {"id": 148, "name": "Sord M5"},
UPS.SPECTRAVIDEO: {"id": 201, "name": "Spectravideo"},
UPS.STV: {"id": 146, "name": "Sega ST-V"},
UPS.SUPER_VISION_8000: {
"id": 223,
"name": "Bandai Super Vision 8000",
},
UPS.SUPERGRAFX: {"id": 162, "name": "PC Engine SuperGrafx"},
UPS.SWITCH: {"id": 211, "name": "Nintendo Switch"},
UPS.SWITCH_2: {"id": 224, "name": "Nintendo Switch 2"},
UPS.TG16: {"id": 54, "name": "NEC TurboGrafx-16"},
UPS.TI_994A: {"id": 149, "name": "Texas Instruments TI 99/4A"},
UPS.TOMY_TUTOR: {"id": 200, "name": "Tomy Tutor"},
UPS.TRS_80: {"id": 129, "name": "Tandy TRS-80"},
UPS.TRS_80_COLOR_COMPUTER: {
"id": 164,
"name": "TRS-80 Color Computer",
},
UPS.TURBOGRAFX_CD: {"id": 163, "name": "NEC TurboGrafx-CD"},
UPS.TYPE_X: {"id": 169, "name": "Taito Type X"},
UPS.VC_4000: {"id": 137, "name": "Interton VC 4000"},
UPS.VECTREX: {"id": 125, "name": "GCE Vectrex"},
UPS.VIC_20: {"id": 122, "name": "Commodore VIC-20"},
UPS.VIDEOPAC_G7400: {"id": 141, "name": "Philips Videopac+"},
UPS.VIRTUALBOY: {"id": 32, "name": "Nintendo Virtual Boy"},
UPS.VMU: {"id": 144, "name": "Sega Dreamcast VMU"},
UPS.VSMILE: {"id": 221, "name": "VTech V.Smile"},
UPS.SUPERVISION: {"id": 153, "name": "Watara Supervision"},
UPS.WII: {"id": 33, "name": "Nintendo Wii"},
UPS.WIIU: {"id": 34, "name": "Nintendo Wii U"},
UPS.WIN: {"id": 84, "name": "Windows"},
UPS.WIN3X: {"id": 212, "name": "Windows 3.X"},
UPS.WONDERSWAN: {"id": 55, "name": "WonderSwan"},
UPS.WONDERSWAN_COLOR: {"id": 56, "name": "WonderSwan Color"},
UPS.X1: {"id": 204, "name": "Sharp X1"},
UPS.XAVIXPORT: {"id": 170, "name": "XaviXPORT"},
UPS.XBOX: {"id": 18, "name": "Microsoft Xbox"},
UPS.XBOX360: {"id": 19, "name": "Microsoft Xbox 360"},
UPS.XBOXONE: {"id": 20, "name": "Microsoft Xbox One"},
UPS.ZINC: {"id": 155, "name": "ZiNc"},
UPS.ZOD: {"id": 75, "name": "Tapwave Zodiac"},
UPS.ZX81: {"id": 147, "name": "Sinclair ZX-81"},
UPS.ZXS: {"id": 46, "name": "Sinclair ZX Spectrum"},
}
LAUNCHBOX_PLATFORM_LIST |= arcade_fallbacks(LAUNCHBOX_PLATFORM_LIST)
fill_duplicate_slugs(LAUNCHBOX_PLATFORM_LIST)
def get_platform(slug: str) -> LaunchboxPlatform:
slug_clean = slug.strip().lower()
resolved: UPS | None = None
for candidate in (
slug_clean,
slug_clean.replace("-", ""),
slug_clean.replace("_", ""),
slug_clean.replace("-", "").replace("_", ""),
):
if not candidate:
continue
try:
ups = UPS(candidate)
except ValueError:
continue
if ups in LAUNCHBOX_PLATFORM_LIST:
resolved = ups
break
if resolved is None:
return LaunchboxPlatform(slug=slug_clean, launchbox_id=None)
platform = LAUNCHBOX_PLATFORM_LIST[resolved]
return LaunchboxPlatform(
slug=slug_clean,
launchbox_id=platform["id"],
name=platform["name"],
)