add and store fake launchbox IDs

This commit is contained in:
Georges-Antoine Assi
2025-05-23 14:13:19 -04:00
parent 69b898a397
commit fd705e41ce
14 changed files with 317 additions and 238 deletions

View File

@@ -90,17 +90,22 @@ class RAHasherService:
"""Service to calculate RetroAchievements hashes using RAHasher."""
async def calculate_hash(self, platform_id: int, file_path: str) -> str:
return ""
log.debug(
f"Executing {hl('RAHasher', color=LIGHTMAGENTA)} for platform: {hl(RA_ID_TO_SLUG[platform_id])} - file: {hl(file_path.split('/')[-1])}"
)
args = (str(platform_id), file_path)
proc = await asyncio.create_subprocess_exec(
"RAHasher",
*args,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
try:
proc = await asyncio.create_subprocess_exec(
"RAHasher",
*args,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
except FileNotFoundError:
log.error("RAHasher executable not found in PATH")
return ""
return_code = await proc.wait()
if return_code != 1:
if proc.stderr is not None:

View File

@@ -8,7 +8,7 @@ Create Date: 2025-01-02 18:58:55.557123
import sqlalchemy as sa
from alembic import op
from handler.metadata.ss_handler import SLUG_TO_SS_ID
from handler.metadata.ss_handler import SCREENSAVER_PLATFORM_LIST
# revision identifiers, used by Alembic.
revision = "0036_screenscraper_platforms_id"
@@ -20,7 +20,7 @@ depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
connection = op.get_bind()
for slug, ss_id in SLUG_TO_SS_ID.items():
for slug, ss_id in SCREENSAVER_PLATFORM_LIST.items():
connection.execute(
sa.text("UPDATE platforms SET ss_id = :ss_id WHERE slug = :slug"),
{"ss_id": ss_id["id"], "slug": slug},

View File

@@ -9,6 +9,7 @@ Create Date: 2025-05-20 22:39:16.993191
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
from utils.database import CustomJSON
revision = "0041_launchbox_id"
down_revision = "0040_migrate_assets_paths"
@@ -20,6 +21,9 @@ def upgrade() -> None:
with op.batch_alter_table("rom_user", schema=None) as batch_op:
batch_op.drop_column("ra_metadata")
with op.batch_alter_table("platforms", schema=None) as batch_op:
batch_op.add_column(sa.Column("launchbox_id", sa.Integer(), nullable=True))
with op.batch_alter_table("roms", schema=None) as batch_op:
batch_op.add_column(sa.Column("launchbox_id", sa.Integer(), nullable=True))
batch_op.add_column(
@@ -37,7 +41,6 @@ def upgrade() -> None:
def downgrade() -> None:
with op.batch_alter_table("roms", schema=None) as batch_op:
batch_op.drop_index("idx_roms_sgdb_id")
batch_op.drop_index("idx_roms_ra_id")
@@ -45,12 +48,8 @@ def downgrade() -> None:
batch_op.drop_column("launchbox_metadata")
batch_op.drop_column("launchbox_id")
with op.batch_alter_table("platforms", schema=None) as batch_op:
batch_op.drop_column("launchbox_id")
with op.batch_alter_table("rom_user", schema=None) as batch_op:
batch_op.add_column(
sa.Column(
"ra_metadata",
postgresql.JSONB(astext_type=sa.Text()),
autoincrement=False,
nullable=True,
)
)
batch_op.add_column(sa.Column("ra_metadata", CustomJSON(), nullable=True))

View File

@@ -17,6 +17,7 @@ class PlatformSchema(BaseModel):
igdb_id: int | None = None
sgdb_id: int | None = None
moby_id: int | None = None
launchbox_id: int | None = None
ss_id: int | None = None
ra_id: int | None = None
category: str | None = None

View File

@@ -255,12 +255,13 @@ async def _identify_platform(
# Keep the existing ids if they exist on the platform
scanned_platform.igdb_id = scanned_platform.igdb_id or platform.igdb_id
scanned_platform.moby_id = scanned_platform.moby_id or platform.moby_id
scanned_platform.launchbox_id = (
scanned_platform.launchbox_id or platform.launchbox_id
)
scan_stats.scanned_platforms += 1
scan_stats.added_platforms += 1 if not platform else 0
scan_stats.metadata_platforms += (
1 if scanned_platform.igdb_id or scanned_platform.moby_id else 0
)
scan_stats.metadata_platforms += 1 if scanned_platform.is_identified else 0
platform = db_platform_handler.add_platform(scanned_platform)
@@ -461,9 +462,7 @@ async def _identify_rom(
scan_stats.scanned_roms += 1
scan_stats.added_roms += 1 if not rom else 0
scan_stats.metadata_roms += (
1 if scanned_rom.igdb_id or scanned_rom.moby_id or scanned_rom.ss_id else 0
)
scan_stats.metadata_roms += 1 if scanned_rom.is_identified else 0
_added_rom = db_rom_handler.add_rom(scanned_rom)

View File

@@ -191,6 +191,7 @@ class DBRomsHandler(DBBaseHandler):
Rom.igdb_id.is_(None),
Rom.moby_id.is_(None),
Rom.ss_id.is_(None),
Rom.launchbox_id.is_(None),
)
)
@@ -200,6 +201,7 @@ class DBRomsHandler(DBBaseHandler):
Rom.igdb_id.isnot(None),
Rom.moby_id.isnot(None),
Rom.ss_id.isnot(None),
Rom.launchbox_id.isnot(None),
)
)
@@ -405,6 +407,9 @@ class DBRomsHandler(DBBaseHandler):
Rom.igdb_id.isnot(None): build_func("igdb", Rom.igdb_id),
Rom.moby_id.isnot(None): build_func("moby", Rom.moby_id),
Rom.ss_id.isnot(None): build_func("ss", Rom.ss_id),
Rom.launchbox_id.isnot(None): build_func(
"launchbox", Rom.launchbox_id
),
},
else_=build_func("romm", Rom.id),
)

View File

@@ -17,6 +17,7 @@ LAUNCHBOX_API_ENABLED: Final = True
class LaunchboxPlatform(TypedDict):
slug: str
launchbox_id: int | None
name: NotRequired[str]
@@ -56,7 +57,9 @@ def extract_metadata_from_launchbox_rom(index_entry: dict) -> LaunchboxMetadata:
"community_rating_count": int(index_entry.get("CommunityRatingCount") or 0),
"wikipedia_url": index_entry.get("WikipediaURL", ""),
"esrb": index_entry.get("ESRB", ""),
"genres": index_entry.get("Genres", []).split(),
"genres": (
index_entry["Genres"].split() if index_entry.get("Genres", None) else []
),
"developer": index_entry.get("Developer") or "",
"publisher": index_entry.get("Publisher") or "",
}
@@ -130,14 +133,15 @@ class LaunchboxHandler(MetadataHandler):
return screenshots
def get_platform(self, slug: str) -> LaunchboxPlatform:
platform_name = SLUG_TO_LAUNCHBOX_PLATFORM_NAME.get(slug, None)
platform = LAUNCHBOX_PLATFORM_LIST.get(slug, None)
if not platform_name:
return LaunchboxPlatform(slug=slug)
if not platform:
return LaunchboxPlatform(slug=slug, launchbox_id=None)
return LaunchboxPlatform(
slug=slug,
name=platform_name,
launchbox_id=platform["id"],
name=platform["name"],
)
async def get_rom(self, fs_name: str) -> LaunchboxRom:
@@ -211,194 +215,189 @@ class SlugToLaunchboxPlatformName(TypedDict):
name: str
SLUG_TO_LAUNCHBOX_PLATFORM_NAME = {
"3do": "3DO Interactive Multiplayer",
"apf": "APF Imagination Machine",
"pegasus": "Aamber Pegasus",
"acorn-archimedes": "Acorn Archimedes",
"atom": "Acorn Atom",
"acorn-electron": "Acorn Electron",
"acpc": "Amstrad CPC",
"gx4000": "Amstrad GX4000",
"android": "Android",
"bk-01": "Apogee BK-01",
"apple2": "Apple II",
"apple2gs": "Apple IIGS",
"mac": "Apple Mac OS",
"ios": "Apple iOS",
"arcade": "Arcade",
"atari2600": "Atari 2600",
"atari5200": "Atari 5200",
"atari7800": "Atari 7800",
"atari800": "Atari 800",
"jaguar": "Atari Jaguar",
"atari-jaguar-cd": "Atari Jaguar CD",
"lynx": "Atari Lynx",
"atari-st": "Atari ST",
"atari-xegs": "Atari XEGS",
"bbcmicro": "BBC Microcomputer System",
"astrocade": "Bally Astrocade",
"super-vision-8000": "Bandai Super Vision 8000",
"camputers-lynx": "Camputers Lynx",
"casio-loopy": "Casio Loopy",
"casio-pv-1000": "Casio PV-1000",
"colecoadam": "Coleco ADAM",
"colecovision": "ColecoVision",
"c128": "Commodore 128",
"c64": "Commodore 64",
"amiga": "Commodore Amiga",
"amiga-cd32": "Commodore Amiga CD32",
"commodore-cdtv": "Commodore CDTV",
"cpet": "Commodore PET",
"c-plus-4": "Commodore Plus 4",
"vic-20": "Commodore VIC-20",
"dragon-32-slash-64": "Dragon 32/64",
"colour-genie": "EACA EG2000 Colour Genie",
"bk": "Elektronika BK",
"arcadia-2001": "Emerson Arcadia 2001",
"enterprise": "Enterprise",
"adventure-vision": "Entex Adventure Vision",
"epoch-game-pocket-computer": "Epoch Game Pocket Computer",
"epoch-super-cassette-vision": "Epoch Super Cassette Vision",
"exelvision": "Exelvision EXL 100",
"exidy-sorcerer": "Exidy Sorcerer",
"fairchild-channel-f": "Fairchild Channel F",
"fm-towns": "Fujitsu FM Towns Marty",
"fm-7": "Fujitsu FM-7",
"super-acan": "Funtech Super Acan",
"vectrex": "GCE Vectrex",
# "game-wave": "Game Wave Family Entertainment System",
"gp32": "GamePark GP32",
"game-wave": "GameWave",
"hartung": "Hartung Game Master",
"hrx": "Hector HRX",
"vc-4000": "Interton VC 4000",
"jupiter-ace": "Jupiter Ace",
"linux": "Linux",
"dos": "MS-DOS",
"mugen": "MUGEN",
"odyssey--1": "Magnavox Odyssey",
"odyssey-2-slash-videopac-g7000": "Magnavox Odyssey 2",
"alice-3290": "Matra and Hachette Alice",
"mattel-aquarius": "Mattel Aquarius",
"hyperscan": "Mattel HyperScan",
"intellivision": "Mattel Intellivision",
"mega-duck-slash-cougar-boy": "Mega Duck",
"mtx512": "Memotech MTX512",
"msx": "Microsoft MSX",
"msx2": "Microsoft MSX2",
"msx2plus": "Microsoft MSX2+",
"xbox": "Microsoft Xbox",
"xbox360": "Microsoft Xbox 360",
"xboxone": "Microsoft Xbox One",
"series-x": "Microsoft Xbox Series X/S",
"pc-8800-series": "NEC PC-8801",
"pc-9800-series": "NEC PC-9801",
"pc-fx": "NEC PC-FX",
"turbografx16--1": "NEC TurboGrafx-16",
"turbografx-16-slash-pc-engine-cd": "NEC TurboGrafx-CD",
"system-32": "Namco System 22",
"3ds": "Nintendo 3DS",
"n64": "Nintendo 64",
"64dd": "Nintendo 64DD",
"nds": "Nintendo DS",
"nes": "Nintendo Entertainment System",
"famicom": "Nintendo Famicom Disk System",
"g-and-w": "Nintendo Game & Watch",
"gb": "Nintendo Game Boy",
"gba": "Nintendo Game Boy Advance",
"gbc": "Nintendo Game Boy Color",
"ngc": "Nintendo GameCube",
"pokemon-mini": "Nintendo Pokemon Mini",
"satellaview": "Nintendo Satellaview",
"switch": "Nintendo Switch",
"switch2": "Nintendo Switch 2",
"virtualboy": "Nintendo Virtual Boy",
"wii": "Nintendo Wii",
"wiiu": "Nintendo Wii U",
"ngage": "Nokia N-Gage",
"nuon": "Nuon",
"openbor": "OpenBOR",
"atmos": "Oric Atmos",
"multivision": "Othello Multivision",
"ouya": "Ouya",
"supergrafx": "PC Engine SuperGrafx",
"pico": "PICO-8",
"philips-cd-i": "Philips CD-i",
"philips-vg-5000": "Philips VG 5000",
"videopac-g7400": "Philips Videopac+",
"pinball": "Pinball",
"rca-studio-ii": "RCA Studio II",
"sam-coupe": "SAM Coupé",
"neogeoaes": "SNK Neo Geo AES",
"neo-geo-cd": "SNK Neo Geo CD",
"neogeomvs": "SNK Neo Geo MVS",
"neo-geo-pocket": "SNK Neo Geo Pocket",
"neo-geo-pocket-color": "SNK Neo Geo Pocket Color",
# "": "Sammy Atomiswave",
"scummvm": "ScummVM",
"sega32": "Sega 32X",
"segacd": "Sega CD",
"segacd32": "Sega CD 32X",
"dc": "Sega Dreamcast",
"vmu": "Sega Dreamcast VMU",
"gamegear": "Sega Game Gear",
"genesis-slash-megadrive": "Sega Genesis",
"hikaru": "Sega Hikaru",
"sms": "Sega Master System",
"model1": "Sega Model 1",
"model2": "Sega Model 2",
"model3": "Sega Model 3",
# "": "Sega Naomi",
# "": "Sega Naomi 2",
"sega-pico": "Sega Pico",
"sc3000": "Sega SC-3000",
"sg1000": "Sega SG-1000",
"stv": "Sega ST-V",
"saturn": "Sega Saturn",
"system16": "Sega System 16",
"system32": "Sega System 32",
# "": "Sega Triforce",
"sharp-mz-80b20002500": "Sharp MZ-2500",
"x1": "Sharp X1",
"sharp-x68000": "Sharp X68000",
"zxs": "Sinclair ZX Spectrum",
"sinclair-zx81": "Sinclair ZX-81",
"psp": "Sony PSP",
"psp-minis": "Sony PSP Minis",
"ps": "Sony Playstation",
"ps2": "Sony Playstation 2",
"ps3": "Sony Playstation 3",
"ps4--1": "Sony Playstation 4",
"ps5": "Sony Playstation 5",
"psvita": "Sony Playstation Vita",
"pocketstation": "Sony PocketStation",
"sord-m5": "Sord M5",
"spectravideo": "Spectravideo",
"snes": "Super Nintendo Entertainment System",
"trs-80-color-computer": "TRS-80 Color Computer",
"type-x": "Taito Type X",
"trs-80": "Tandy TRS-80",
"zod": "Tapwave Zodiac",
"ti-994a": "Texas Instruments TI 99/4A",
"game-dot-com": "Tiger Game.com",
"tomy-tutor": "Tomy Tutor",
"creativision": "VTech CreatiVision",
"socrates": "VTech Socrates",
"vsmile": "VTech V.Smile",
"06c": "Vector-06C",
"watara-slash-quickshot-supervision": "Watara Supervision",
"browser": "Web Browser",
"win": "Windows",
"win3x": "Windows 3.X",
"action-max": "WoW Action Max",
"wonderswan": "WonderSwan",
"wonderswan-color": "WonderSwan Color",
"xavixport": "XaviXPORT",
"zinc": "ZiNc",
LAUNCHBOX_PLATFORM_LIST: dict[str, SlugToLaunchboxPlatformName] = {
"3do": {"id": 1, "name": "3DO Interactive Multiplayer"},
"apf": {"id": 2, "name": "APF Imagination Machine"},
"pegasus": {"id": 3, "name": "Aamber Pegasus"},
"acorn-archimedes": {"id": 4, "name": "Acorn Archimedes"},
"atom": {"id": 5, "name": "Acorn Atom"},
"acorn-electron": {"id": 6, "name": "Acorn Electron"},
"acpc": {"id": 7, "name": "Amstrad CPC"},
"gx4000": {"id": 8, "name": "Amstrad GX4000"},
"android": {"id": 9, "name": "Android"},
"bk-01": {"id": 10, "name": "Apogee BK-01"},
"apple2": {"id": 11, "name": "Apple II"},
"apple2gs": {"id": 12, "name": "Apple IIGS"},
"mac": {"id": 13, "name": "Apple Mac OS"},
"ios": {"id": 14, "name": "Apple iOS"},
"arcade": {"id": 15, "name": "Arcade"},
"atari2600": {"id": 16, "name": "Atari 2600"},
"atari5200": {"id": 17, "name": "Atari 5200"},
"atari7800": {"id": 18, "name": "Atari 7800"},
"atari800": {"id": 19, "name": "Atari 800"},
"jaguar": {"id": 20, "name": "Atari Jaguar"},
"atari-jaguar-cd": {"id": 21, "name": "Atari Jaguar CD"},
"lynx": {"id": 22, "name": "Atari Lynx"},
"atari-st": {"id": 23, "name": "Atari ST"},
"atari-xegs": {"id": 24, "name": "Atari XEGS"},
"bbcmicro": {"id": 25, "name": "BBC Microcomputer System"},
"astrocade": {"id": 26, "name": "Bally Astrocade"},
"super-vision-8000": {"id": 27, "name": "Bandai Super Vision 8000"},
"camputers-lynx": {"id": 28, "name": "Camputers Lynx"},
"casio-loopy": {"id": 29, "name": "Casio Loopy"},
"casio-pv-1000": {"id": 30, "name": "Casio PV-1000"},
"colecoadam": {"id": 31, "name": "Coleco ADAM"},
"colecovision": {"id": 32, "name": "ColecoVision"},
"c128": {"id": 33, "name": "Commodore 128"},
"c64": {"id": 34, "name": "Commodore 64"},
"amiga": {"id": 35, "name": "Commodore Amiga"},
"amiga-cd32": {"id": 36, "name": "Commodore Amiga CD32"},
"commodore-cdtv": {"id": 37, "name": "Commodore CDTV"},
"cpet": {"id": 38, "name": "Commodore PET"},
"c-plus-4": {"id": 39, "name": "Commodore Plus 4"},
"vic-20": {"id": 40, "name": "Commodore VIC-20"},
"dragon-32-slash-64": {"id": 41, "name": "Dragon 32/64"},
"colour-genie": {"id": 42, "name": "EACA EG2000 Colour Genie"},
"bk": {"id": 43, "name": "Elektronika BK"},
"arcadia-2001": {"id": 44, "name": "Emerson Arcadia 2001"},
"enterprise": {"id": 45, "name": "Enterprise"},
"adventure-vision": {"id": 46, "name": "Entex Adventure Vision"},
"epoch-game-pocket-computer": {"id": 47, "name": "Epoch Game Pocket Computer"},
"epoch-super-cassette-vision": {"id": 48, "name": "Epoch Super Cassette Vision"},
"exelvision": {"id": 49, "name": "Exelvision EXL 100"},
"exidy-sorcerer": {"id": 50, "name": "Exidy Sorcerer"},
"fairchild-channel-f": {"id": 51, "name": "Fairchild Channel F"},
"fm-towns": {"id": 52, "name": "Fujitsu FM Towns Marty"},
"fm-7": {"id": 53, "name": "Fujitsu FM-7"},
"super-acan": {"id": 54, "name": "Funtech Super Acan"},
"vectrex": {"id": 55, "name": "GCE Vectrex"},
"gp32": {"id": 56, "name": "GamePark GP32"},
"game-wave": {"id": 57, "name": "GameWave"},
"hartung": {"id": 58, "name": "Hartung Game Master"},
"hrx": {"id": 59, "name": "Hector HRX"},
"vc-4000": {"id": 60, "name": "Interton VC 4000"},
"jupiter-ace": {"id": 61, "name": "Jupiter Ace"},
"linux": {"id": 62, "name": "Linux"},
"dos": {"id": 63, "name": "MS-DOS"},
"mugen": {"id": 64, "name": "MUGEN"},
"odyssey--1": {"id": 65, "name": "Magnavox Odyssey"},
"odyssey-2-slash-videopac-g7000": {"id": 66, "name": "Magnavox Odyssey 2"},
"alice-3290": {"id": 67, "name": "Matra and Hachette Alice"},
"mattel-aquarius": {"id": 68, "name": "Mattel Aquarius"},
"hyperscan": {"id": 69, "name": "Mattel HyperScan"},
"intellivision": {"id": 70, "name": "Mattel Intellivision"},
"mega-duck-slash-cougar-boy": {"id": 71, "name": "Mega Duck"},
"mtx512": {"id": 72, "name": "Memotech MTX512"},
"msx": {"id": 73, "name": "Microsoft MSX"},
"msx2": {"id": 74, "name": "Microsoft MSX2"},
"msx2plus": {"id": 75, "name": "Microsoft MSX2+"},
"xbox": {"id": 76, "name": "Microsoft Xbox"},
"xbox360": {"id": 77, "name": "Microsoft Xbox 360"},
"xboxone": {"id": 78, "name": "Microsoft Xbox One"},
"series-x": {"id": 79, "name": "Microsoft Xbox Series X/S"},
"pc-8800-series": {"id": 80, "name": "NEC PC-8801"},
"pc-9800-series": {"id": 81, "name": "NEC PC-9801"},
"pc-fx": {"id": 82, "name": "NEC PC-FX"},
"turbografx16--1": {"id": 83, "name": "NEC TurboGrafx-16"},
"turbografx-16-slash-pc-engine-cd": {"id": 84, "name": "NEC TurboGrafx-CD"},
"system-32": {"id": 85, "name": "Namco System 22"},
"3ds": {"id": 86, "name": "Nintendo 3DS"},
"n64": {"id": 87, "name": "Nintendo 64"},
"64dd": {"id": 88, "name": "Nintendo 64DD"},
"nds": {"id": 89, "name": "Nintendo DS"},
"nes": {"id": 90, "name": "Nintendo Entertainment System"},
"famicom": {"id": 91, "name": "Nintendo Famicom Disk System"},
"g-and-w": {"id": 92, "name": "Nintendo Game & Watch"},
"gb": {"id": 93, "name": "Nintendo Game Boy"},
"gba": {"id": 94, "name": "Nintendo Game Boy Advance"},
"gbc": {"id": 95, "name": "Nintendo Game Boy Color"},
"ngc": {"id": 96, "name": "Nintendo GameCube"},
"pokemon-mini": {"id": 97, "name": "Nintendo Pokemon Mini"},
"satellaview": {"id": 98, "name": "Nintendo Satellaview"},
"switch": {"id": 99, "name": "Nintendo Switch"},
"switch2": {"id": 100, "name": "Nintendo Switch 2"},
"virtualboy": {"id": 101, "name": "Nintendo Virtual Boy"},
"wii": {"id": 102, "name": "Nintendo Wii"},
"wiiu": {"id": 103, "name": "Nintendo Wii U"},
"ngage": {"id": 104, "name": "Nokia N-Gage"},
"nuon": {"id": 105, "name": "Nuon"},
"openbor": {"id": 106, "name": "OpenBOR"},
"atmos": {"id": 107, "name": "Oric Atmos"},
"multivision": {"id": 108, "name": "Othello Multivision"},
"ouya": {"id": 109, "name": "Ouya"},
"supergrafx": {"id": 110, "name": "PC Engine SuperGrafx"},
"pico": {"id": 111, "name": "PICO-8"},
"philips-cd-i": {"id": 112, "name": "Philips CD-i"},
"philips-vg-5000": {"id": 113, "name": "Philips VG 5000"},
"videopac-g7400": {"id": 114, "name": "Philips Videopac+"},
"pinball": {"id": 115, "name": "Pinball"},
"rca-studio-ii": {"id": 116, "name": "RCA Studio II"},
"sam-coupe": {"id": 117, "name": "SAM Coupé"},
"neogeoaes": {"id": 118, "name": "SNK Neo Geo AES"},
"neo-geo-cd": {"id": 119, "name": "SNK Neo Geo CD"},
"neogeomvs": {"id": 120, "name": "SNK Neo Geo MVS"},
"neo-geo-pocket": {"id": 121, "name": "SNK Neo Geo Pocket"},
"neo-geo-pocket-color": {"id": 122, "name": "SNK Neo Geo Pocket Color"},
"scummvm": {"id": 123, "name": "ScummVM"},
"sega32": {"id": 124, "name": "Sega 32X"},
"segacd": {"id": 125, "name": "Sega CD"},
"segacd32": {"id": 126, "name": "Sega CD 32X"},
"dc": {"id": 127, "name": "Sega Dreamcast"},
"vmu": {"id": 128, "name": "Sega Dreamcast VMU"},
"gamegear": {"id": 129, "name": "Sega Game Gear"},
"genesis-slash-megadrive": {"id": 130, "name": "Sega Genesis"},
"hikaru": {"id": 131, "name": "Sega Hikaru"},
"sms": {"id": 132, "name": "Sega Master System"},
"model1": {"id": 133, "name": "Sega Model 1"},
"model2": {"id": 134, "name": "Sega Model 2"},
"model3": {"id": 135, "name": "Sega Model 3"},
"sega-pico": {"id": 136, "name": "Sega Pico"},
"sc3000": {"id": 137, "name": "Sega SC-3000"},
"sg1000": {"id": 138, "name": "Sega SG-1000"},
"stv": {"id": 139, "name": "Sega ST-V"},
"saturn": {"id": 140, "name": "Sega Saturn"},
"system16": {"id": 141, "name": "Sega System 16"},
"system32": {"id": 142, "name": "Sega System 32"},
"sharp-mz-80b20002500": {"id": 143, "name": "Sharp MZ-2500"},
"x1": {"id": 144, "name": "Sharp X1"},
"sharp-x68000": {"id": 145, "name": "Sharp X68000"},
"zxs": {"id": 146, "name": "Sinclair ZX Spectrum"},
"sinclair-zx81": {"id": 147, "name": "Sinclair ZX-81"},
"psp": {"id": 148, "name": "Sony PSP"},
"psp-minis": {"id": 149, "name": "Sony PSP Minis"},
"ps": {"id": 150, "name": "Sony Playstation"},
"ps2": {"id": 151, "name": "Sony Playstation 2"},
"ps3": {"id": 152, "name": "Sony Playstation 3"},
"ps4--1": {"id": 153, "name": "Sony Playstation 4"},
"ps5": {"id": 154, "name": "Sony Playstation 5"},
"psvita": {"id": 155, "name": "Sony Playstation Vita"},
"pocketstation": {"id": 156, "name": "Sony PocketStation"},
"sord-m5": {"id": 157, "name": "Sord M5"},
"spectravideo": {"id": 158, "name": "Spectravideo"},
"snes": {"id": 159, "name": "Super Nintendo Entertainment System"},
"trs-80-color-computer": {"id": 160, "name": "TRS-80 Color Computer"},
"type-x": {"id": 161, "name": "Taito Type X"},
"trs-80": {"id": 162, "name": "Tandy TRS-80"},
"zod": {"id": 163, "name": "Tapwave Zodiac"},
"ti-994a": {"id": 164, "name": "Texas Instruments TI 99/4A"},
"game-dot-com": {"id": 165, "name": "Tiger Game.com"},
"tomy-tutor": {"id": 166, "name": "Tomy Tutor"},
"creativision": {"id": 167, "name": "VTech CreatiVision"},
"socrates": {"id": 168, "name": "VTech Socrates"},
"vsmile": {"id": 169, "name": "VTech V.Smile"},
"06c": {"id": 170, "name": "Vector-06C"},
"watara-slash-quickshot-supervision": {"id": 171, "name": "Watara Supervision"},
"browser": {"id": 172, "name": "Web Browser"},
"win": {"id": 173, "name": "Windows"},
"win3x": {"id": 174, "name": "Windows 3.X"},
"action-max": {"id": 175, "name": "WoW Action Max"},
"wonderswan": {"id": 176, "name": "WonderSwan"},
"wonderswan-color": {"id": 177, "name": "WonderSwan Color"},
"xavixport": {"id": 178, "name": "XaviXPORT"},
"zinc": {"id": 179, "name": "ZiNc"},
}
# Reverse lookup
LAUNCHBOX_PLATFORM_NAME_TO_SLUG = {
v: k for k, v in SLUG_TO_LAUNCHBOX_PLATFORM_NAME.items()
v["id"]: k for k, v in LAUNCHBOX_PLATFORM_LIST.items()
}

View File

@@ -178,7 +178,7 @@ class MobyGamesHandler(MetadataHandler):
return pydash.get(exact_matches or roms, "[0]", None)
def get_platform(self, slug: str) -> MobyGamesPlatform:
platform = SLUG_TO_MOBY_ID.get(slug, None)
platform = MOBYGAMES_PLATFORM_LIST.get(slug, None)
if not platform:
return MobyGamesPlatform(moby_id=None, slug=slug)
@@ -357,7 +357,7 @@ class SlugToMobyId(TypedDict):
name: str
SLUG_TO_MOBY_ID: dict[str, SlugToMobyId] = {
MOBYGAMES_PLATFORM_LIST: dict[str, SlugToMobyId] = {
"1292-advanced-programmable-video-system": {
"id": 253,
"name": "1292 Advanced Programmable Video System",
@@ -759,4 +759,4 @@ SLUG_TO_MOBY_ID: dict[str, SlugToMobyId] = {
}
# Reverse lookup
MOBY_ID_TO_SLUG = {v["id"]: k for k, v in SLUG_TO_MOBY_ID.items()}
MOBY_ID_TO_SLUG = {v["id"]: k for k, v in MOBYGAMES_PLATFORM_LIST.items()}

View File

@@ -331,7 +331,7 @@ class SSHandler(MetadataHandler):
return pydash.get(roms, "[0]", None)
def get_platform(self, slug: str) -> SSPlatform:
platform = SLUG_TO_SS_ID.get(slug, None)
platform = SCREENSAVER_PLATFORM_LIST.get(slug, None)
if not platform:
return SSPlatform(ss_id=None, slug=slug)
@@ -675,7 +675,7 @@ class SlugToSSId(TypedDict):
name: str
SLUG_TO_SS_ID: dict[str, SlugToSSId] = {
SCREENSAVER_PLATFORM_LIST: dict[str, SlugToSSId] = {
"3do": {"id": 29, "name": "3DO"},
"amiga": {"id": 64, "name": "Amiga"},
"amiga-cd32": {"id": 134, "name": "Amiga CD"},
@@ -854,4 +854,4 @@ SLUG_TO_SS_ID: dict[str, SlugToSSId] = {
}
# Reverse lookup
SS_ID_TO_SLUG = {v["id"]: k for k, v in SLUG_TO_SS_ID.items()}
SS_ID_TO_SLUG = {v["id"]: k for k, v in SCREENSAVER_PLATFORM_LIST.items()}

View File

@@ -155,7 +155,7 @@ async def scan_platform(
launchbox_platform = (
meta_launchbox_handler.get_platform(platform_attrs["slug"])
if MetadataSource.LB in metadata_sources
else LaunchboxPlatform(slug=platform_attrs["slug"])
else LaunchboxPlatform(launchbox_id=None, slug=platform_attrs["slug"])
)
platform_attrs["name"] = platform_attrs["slug"].replace("-", " ").title()
@@ -173,6 +173,7 @@ async def scan_platform(
platform_attrs["igdb_id"]
or platform_attrs["moby_id"]
or platform_attrs["ss_id"]
or platform_attrs["launchbox_id"]
):
log.info(
emoji.emojize(
@@ -272,6 +273,7 @@ async def scan_rom(
"ss_id": rom.ss_id,
"sgdb_id": rom.sgdb_id,
"ra_id": rom.ra_id,
"launchbox_id": rom.launchbox_id,
"name": rom.name,
"slug": rom.slug,
"summary": rom.summary,

View File

@@ -24,6 +24,7 @@ class Platform(BaseModel):
moby_id: Mapped[int | None]
ss_id: Mapped[int | None]
ra_id: Mapped[int | None]
launchbox_id: Mapped[int | None]
slug: Mapped[str] = mapped_column(String(length=100))
fs_slug: Mapped[str] = mapped_column(String(length=100))
name: Mapped[str] = mapped_column(String(length=400))
@@ -55,7 +56,12 @@ class Platform(BaseModel):
@property
def is_unidentified(self) -> bool:
return not self.igdb_id and not self.moby_id and not self.ss_id
return (
not self.igdb_id
and not self.moby_id
and not self.ss_id
and not self.launchbox_id
)
@property
def is_identified(self) -> bool:
@@ -63,7 +69,12 @@ class Platform(BaseModel):
@property
def is_fully_identified(self) -> bool:
return bool(self.igdb_id) and bool(self.moby_id) and bool(self.ss_id)
return (
bool(self.igdb_id)
and bool(self.moby_id)
and bool(self.ss_id)
and bool(self.launchbox_id)
)
@cached_property
def fs_size_bytes(self) -> int:

View File

@@ -2,7 +2,9 @@
from typing import TypedDict
from handler.metadata.igdb_handler import IGDB_PLATFORM_LIST
from handler.metadata.moby_handler import SLUG_TO_MOBY_ID
from handler.metadata.launchbox_handler import LAUNCHBOX_PLATFORM_LIST
from handler.metadata.moby_handler import MOBYGAMES_PLATFORM_LIST
from handler.metadata.ss_handler import SCREENSAVER_PLATFORM_LIST
IGDB_SLUG_TO_MOBY_SLUG = {
"bbcmicro": "bbc-micro",
@@ -75,6 +77,8 @@ class SupportedPlatform(TypedDict):
name: str
igdb_slug: str | None
moby_slug: str | None
ss_slug: str | None
lb_slug: str | None
if __name__ == "__main__":
@@ -82,18 +86,24 @@ if __name__ == "__main__":
matched_moby_slugs: list[str] = []
for plt in IGDB_PLATFORM_LIST:
moby_slug = plt["slug"] if plt["slug"] in SLUG_TO_MOBY_ID else None
moby_slug = plt["slug"] if plt["slug"] in MOBYGAMES_PLATFORM_LIST else None
moby_slug = IGDB_SLUG_TO_MOBY_SLUG.get(plt["slug"], moby_slug)
ss_slug = plt["slug"] if plt["slug"] in SCREENSAVER_PLATFORM_LIST else None
lb_slug = plt["slug"] if plt["slug"] in LAUNCHBOX_PLATFORM_LIST else None
supported_platforms[plt["name"]] = {
"name": plt["name"],
"igdb_slug": plt["slug"],
"moby_slug": moby_slug,
"ss_slug": ss_slug,
"lb_slug": lb_slug,
}
if moby_slug:
matched_moby_slugs.append(moby_slug)
# Now go over the moby ids
for slug, pltf in SLUG_TO_MOBY_ID.items():
for slug, pltf in MOBYGAMES_PLATFORM_LIST.items():
if (
pltf["name"] not in supported_platforms
and pltf["name"].lower() not in supported_platforms
@@ -103,6 +113,37 @@ if __name__ == "__main__":
"name": pltf["name"],
"igdb_slug": None,
"moby_slug": slug,
"ss_slug": None,
"lb_slug": None,
}
# And the remaining metadata sources
for slug, pltf in SCREENSAVER_PLATFORM_LIST.items():
if (
pltf["name"] not in supported_platforms
and pltf["name"].lower() not in supported_platforms
and slug not in matched_moby_slugs
):
supported_platforms[pltf["name"]] = {
"name": pltf["name"],
"igdb_slug": None,
"moby_slug": None,
"ss_slug": slug,
"lb_slug": None,
}
for slug, pltf in LAUNCHBOX_PLATFORM_LIST.items():
if (
pltf["name"] not in supported_platforms
and pltf["name"].lower() not in supported_platforms
and slug not in matched_moby_slugs
):
supported_platforms[pltf["name"]] = {
"name": pltf["name"],
"igdb_slug": None,
"moby_slug": None,
"ss_slug": None,
"lb_slug": slug,
}
# Sort platforms by key
@@ -112,7 +153,7 @@ if __name__ == "__main__":
"Below is a list of all supported platforms/systems/consoles and their respective folder names. **The folder name is case-sensitive and must be used exactly as it appears in the list below.**"
)
print("\n")
print("|Platform Name|Folder Name|IGDB|Mobygames|")
print("|Platform Name|Folder Name|IGDB|Mobygames|ScreenSaver.fr|LaunchBox|")
print("|---|---|---|---|")
for platform in supported_platforms.values():
@@ -129,4 +170,14 @@ if __name__ == "__main__":
if platform["moby_slug"]
else " |"
),
(
f'<a href="https://www.screensaver.fr/roms/{platform["ss_slug"]}" target="_blank" rel="noopener norefer">ScreenSaver.fr</a>'
if platform["ss_slug"]
else " |"
),
(
f'<a href="https://gamesdb.launchbox-app.com/platforms/details/{platform["lb_slug"]}" target="_blank" rel="noopener norefer">LaunchBox</a>'
if platform["lb_slug"]
else " |"
),
)

View File

@@ -13,6 +13,7 @@ export type PlatformSchema = {
igdb_id?: (number | null);
sgdb_id?: (number | null);
moby_id?: (number | null);
launchbox_id?: (number | null);
ss_id?: (number | null);
ra_id?: (number | null);
category?: (string | null);

View File

@@ -315,9 +315,7 @@ watch(
style="text-decoration: none; color: inherit"
:href="`https://www.screenscraper.fr/systemeinfos.php?plateforme=${currentPlatform.ss_id}`"
target="_blank"
:class="{
'ml-1': currentPlatform.igdb_id || currentPlatform.moby_id,
}"
class="ml-1"
>
<v-chip class="pl-0 mt-1" size="small" @click.stop>
<v-avatar class="mr-2" size="30" rounded="0">
@@ -330,7 +328,7 @@ watch(
v-if="currentPlatform.moby_id"
style="text-decoration: none; color: inherit"
target="_blank"
:class="{ 'ml-1': currentPlatform.igdb_id }"
class="ml-1"
>
<v-chip class="pl-0 mt-1" size="small" @click.stop>
<v-avatar class="mr-2" size="30" rounded="0">
@@ -343,12 +341,7 @@ watch(
v-if="currentPlatform.ra_id"
style="text-decoration: none; color: inherit"
target="_blank"
:class="{
'ml-1':
currentPlatform.ra_id ||
currentPlatform.ss_id ||
currentPlatform.moby_id,
}"
class="ml-1"
>
<v-chip class="pl-0 mt-1" size="small" @click.stop>
<v-avatar class="mr-2" size="25" rounded="1">
@@ -357,6 +350,19 @@ watch(
<span>{{ currentPlatform.ra_id }}</span>
</v-chip>
</a>
<a
v-if="currentPlatform.launchbox_id"
style="text-decoration: none; color: inherit"
target="_blank"
class="ml-1"
>
<v-chip class="pl-0 mt-1" size="small" @click.stop>
<v-avatar class="mr-2" size="25" rounded="1">
<v-img src="/assets/scrappers/launchbox.png" />
</v-avatar>
<span>{{ currentPlatform.launchbox_id }}</span>
</v-chip>
</a>
</v-col>
</v-row>
<v-card class="mt-4 bg-toplayer fill-width" elevation="0">