feat(backend): categorize Switch rom files by title ID - #3876
Closed
lucid-void wants to merge 2 commits into
Closed
Conversation
Assign base game / update / DLC categories to Nintendo Switch and Switch 2 rom files from the title ID in their filename, so files sharing a game folder are tagged individually without needing update/ or dlc/ subfolders. Falls back to this only when the directory layout doesn't already categorize the file, and reuses the existing title ID regex. Closes rommapp#2526 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Greptile SummaryThis PR categorizes loose Nintendo Switch ROM files from title IDs in their filenames. The main changes are:
Confidence Score: 4/5The filename parsing path needs to recognize lowercase title IDs before merging.
backend/handler/filesystem/roms_handler.py Important Files Changed
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
backend/handler/filesystem/roms_handler.py:126
**Lowercase Title IDs Stay Unclassified**
`SWITCH_PRODUCT_ID_REGEX` accepts only uppercase hexadecimal characters, so a valid filename such as `Zelda [01007ef00011e800].nsp` produces no match. The fallback then leaves the update uncategorized instead of assigning `UPDATE`.
```suggestion
match = SWITCH_PRODUCT_ID_REGEX.search(file_name.upper())
```
Reviews (1): Last reviewed commit: "feat(backend): categorize Switch rom fil..." | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Member
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Automatically categorizes Nintendo Switch / Switch 2 ROM files as base game, update, or DLC based on the title ID in their filename, so base + update(s) + DLC belonging to the same game can live loose in a single game folder and still be tagged individually, without requiring update/ or dlc/ subfolders.
Today, a file's RomFileCategory is derived only from the folder it sits in (e.g. a file under update/ becomes an UPDATE). This PR adds a fallback: when a Switch/Switch-2 file isn't already categorized by its directory layout, its 16-hex Nintendo title ID is parsed from the filename and classified per the rules from #2526:
Example (Breath of the Wild):
┌────────┬──────────────────┬──────────┐
│ File │ Title ID │ Category │
├────────┼──────────────────┼──────────┤
│ Base │ 01007EF00011E000 │ GAME │
├────────┼──────────────────┼──────────┤
│ Update │ 01007EF00011E800 │ UPDATE │
├────────┼──────────────────┼──────────┤
│ DLC 1 │ 01007EF00011F001 │ DLC │
├────────┼──────────────────┼──────────┤
│ DLC 2 │ 01007EF00011F002 │ DLC │
└────────┴──────────────────┴──────────┘
Notes / scope:
Implementation: a switch_title_id_category() helper plus a fallback branch in _build_rom_file, both in backend/handler/filesystem/roms_handler.py.
▎ AI assistance disclosure: This change was implemented with AI assistance (Claude Code). The title-ID classification logic, the fallback wiring in _build_rom_file, and the accompanying tests were AI-generated and reviewed/verified by me before submitting.
Closes #2526
Checklist