Skip to content

Platform registry + search-context detection for retro consoles (implements #61) - #62

Merged
JeremiahM37 merged 9 commits into
JeremiahM37:mainfrom
zelladir:platform-registry
Sep 29, 2026
Merged

JeremiahM37 merged 9 commits into
JeremiahM37:mainfrom
zelladir:platform-registry

Conversation

@zelladir

Copy link
Copy Markdown
Contributor

Implements the proposal in #61. Stacked on #60 (standard Newznab console categories) — the first commit here is #60; review/merge that first and this PR's diff shrinks to the four commits below. Opened as a draft so you can say whether you want it whole, split, or trimmed.

Commits

  1. Add a platform registry as the single source of platform data — one table per platform (slug, name, categories, extensions, size range, RAWG ids, name hints). PlatformMap, ExtraPlatforms, extension maps, organize/library detection, scoring size bands, Torznab categories, RAWG mapping and /api/platforms all derive from it; existing exported signatures are unchanged.
  2. Keep generic-category results in platform-filtered searches — a filtered console search keeps results that only carry 1000/1090/unknown categories and assigns them the searched platform; results whose category names another platform are still dropped. PC searches behave as before.
  3. Check a download's platform against its ROM files on import — unknown-platform jobs are resolved from unique ROM extensions (including inside zips); if a job's files clearly belong to another platform it's refiled with a warning. A platform chosen manually via Organize is never overridden.
  4. Optionally route ROM hacks to <slug>-hacks — HACKS_SUFFIX_ROUTING (default off) for [h…], [T+/-…], (Hack) releases.

Adds retro platforms with RomM-compatible slugs (gbc, sms, gamegear, segacd, sega32, tg16, turbografx-cd, neogeoaes, neo-geo-cd, ngp, atari5200, atari7800, lynx, colecovision, fds, virtualboy, wonderswan-color, 3do, cdi, msx, c64, amiga, dos, pc98, vectrex, satellaview, sega-pico, g-and-w). Arcade and current-gen consoles deliberately left out.

Behaviour changes worth a look

  • Name hints now use whole-word, longest match (previously a substring check could match e.g. "nds" inside "friends").
  • A few inconsistent table entries were aligned (n64 display name, amiga RAWG id, PS Vita → psvita, 1060 WiiWare → Wii); README's slug table fixed (dc/ngc, no PS5).
  • Known limit: disc images (.iso/.chd/.cue/.bin) can't be verified by extension, so a mislabelled Console/Other disc result stays under the searched platform.

Testing

gofmt, go vet clean; go test ./... — 749 tests pass. (TestRecoverOrphanedTorrentsIsIdempotent is flaky ~3/200 on unmodified main too; unrelated.)

Code drafted with AI assistance; full test suite run before submitting.

zelladir and others added 9 commits September 28, 2026 18:08
Platforms were defined in about nine places - the category map, the extra
platform list, metadata.json names, two extension tables, the manual import
switch, the library scan's extension list and display names, orphan
recovery hints, scoring size bands, Torznab routing and RAWG ids - and they
had drifted apart (GBC was detectable by extension but not a platform,
Atari 2600 was a source slug with no platform behind it).

internal/platform/registry.go now holds one entry per platform: RomM slug,
name, owned and extra search categories, unique ROM extensions, hint-only
formats, size band, RAWG ids and names, metadata aliases and a title hint.
Every existing table and exported function is derived from it and keeps its
signature. Title hints resolve by longest match, so "Xbox 360" still beats
"Xbox" without relying on list order, and extension detection now votes by
file count, looks inside .zip archives, and is deterministic.

Adds GBC, Master System, Game Gear, Sega CD, 32X, PC Engine/TurboGrafx-16,
PC Engine CD, Neo Geo AES/MVS, Neo Geo CD, Neo Geo Pocket, Atari
2600/5200/7800, Lynx, ColecoVision, Famicom Disk System, Virtual Boy,
WonderSwan, 3DO, CD-i, MSX, C64, Amiga, DOS, PC-98, Vectrex, Satellaview,
Sega Pico and Game & Watch. Arcade and current-generation consoles stay out.

/api/platforms lists the registry in order, so the UI follows it. Test
expectations change where the old tables disagreed with each other: manual
import now names n64 "Nintendo 64" like everywhere else, and Amiga and
Atari 2600 now have RAWG mappings.
A platform-filtered Prowlarr search used to keep a result only when one of
its categories was in the platform's category list. Retro systems have no
Newznab subcategory and trackers rarely have one either, so their releases
arrive as Console, Console/Other, an unmapped tracker category or nothing,
and were either dropped or kept as "Unknown" - and for a platform with no
categories of its own every categorised result passed, PS2 releases in a
SNES search included.

The filter now asks the registry (platform.SearchContext). A category the
platform owns keeps the result under that platform; a category that
positively names something else - another platform, PC, an unmapped console
subcategory such as Xbox One, or a non-game Newznab range - drops it; and a
result with only generic, unknown or no categories is kept and assigned the
searched platform, which then travels with the result into the download
job and decides the import folder. A PC repack name drops an otherwise
generic result. PC searches, Switch's PC/Games request for Nyaa, and slugs
outside the registry keep their previous behaviour.
Search context can now file a Console/Other result under the platform that
was searched for, which is right for a SNES search that finds a SNES ROM and
wrong when the release turns out to be a GBA ROM. Import already detected
the platform from files when a job had none; it now also checks a console
platform the job does carry.

When none of the downloaded files is a format the job's platform uses and
the unique ROM extensions among them (loose, in subfolders, or inside a
.zip) all point at another platform, the job is refiled there and the row
updated, with a warning in the log. Content that includes any of the
platform's own formats is never second-guessed, so a Switch release with a
stray .nes inside stays a Switch release, and shared disc formats (.iso,
.chd, .cue, .bin) never count as evidence. A platform picked by hand with
the Organize button is marked on the job and left alone.
HACKS_SUFFIX_ROUTING=true (default false) files a ROM whose release or file
name looks like a hack or fan translation under GAMES_ROMS_PATH/<slug>-hacks
instead of <slug>, so RomM can keep them apart from the clean set. A name
counts as a hack when it carries a GoodTools/RHDN [h...] tag (lowercase h,
so [HD] does not match), a [T+...]/[T-...] translation tag, (Hack), or the
word "hack" ("ROM hack" included, the .hack// series excluded).

All four ROM destinations honour it: torrent import, DDL, Usenet (including
the restart-recovery lookup) and manual import. The library scan names a
hacks folder after its platform ("SNES Hacks") and accepts that platform's
own formats inside it.
@JeremiahM37
JeremiahM37 marked this pull request as ready for review September 29, 2026 06:43
@JeremiahM37
JeremiahM37 merged commit 74a6f5c into JeremiahM37:main Sep 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants